Quick == in VS

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
Is there a way of asking Visual Studio to create an equivilence operator for structs and/or classes such that == is defined as all of it's elements being equivilent.

Have an example:

class ComplexNumber {
* private int re,im;
}

and ask VS to derive the equivilence relation:

public static bool operator== (ComplexNumber a, ComplexNumber b){
* return a.re == b.re && a.im == b.im;
}


but for much larger numbers of fields (say 20+)?

Before anyone suggests it, I don't want to use reflection, and although I can type them in manually, it means that if fields are added to the class later then unless someone shrewdly adds said field into the == function, it might break the equivilence.


More...

View All Our Microsft Related Feeds
 
Back
Top