Decrement Operator Overloading C# with Example
using System; namespace CSharpClass { class Coordinate { int x {get; set;} int y {get; set;} public Coordinate(){} public Coordinate(int x, int y) { this.x = x; this.y = y; } public void Position(string type) { Console.WriteLine("{0} Position: {1},{2}", type, x, y); } public static Coordinate operator +(Coordinate operand1, Coordinate operand2) { Coordinate temp = new Coordinate(); temp.x = operand1.x + operand2.x; temp.y = operand1.y + operand2.y; return temp; } public static Coordinate operator --(Coordinate operand) { Coordinate temp = new Coordinate(); temp.x = --operand.x; temp.y = --operand.y; return temp; } } class OperatorOverloadingBasic { static void Main() { Coordinate pixel = new Coordinate(12,21); pixel.Position("Before Decrement Pixel is Positioned at: "); pixel--; pixel.Position("After Decrement Pixel is Positioned at: "); } } }