[Example: The following example shows an implementation and subsequent usage of operator++ for an integer vector class:
public class IntVector
{
public int Length { ... } // read-only property
public int this[int index] { ... } // read-write indexer
public IntVector(int vectorLength) { ... }
public static IntVector operator++(IntVector iv) {
IntVector temp = new IntVector(iv.Length);
for (int i = 0; i < iv.Length; ++i)
temp[i] = iv[i] + 1;
return temp;
}
}
class Test
{
static void Main() {
IntVector iv1 = new IntVector(4); // vector of 4x0
IntVector iv2;
iv2 = iv1++; // iv2 contains 4x0, iv1 contains 4x1
iv2 = ++iv1; // iv2 contains 4x2, iv1 contains 4x2
}