How can I add bool Equals(object obj)
method to class that is created automatically (in my case by edmx model).
One solution that I mean is to inherit this class and use this new class, but I'm looking for something different.
The class is partial, so you can create a new partial class.
public partial class MyClass
{
bool Equals(object obj)
{
// code here
}
}
You can use Extension Methods
public static class ExM
{
public static bool Equals(this MyClass obj1, MyClass obj2)
{
// code here
}
}
It will add that method Equals
in Intellisense of MyClass object so that when you call it like this
bool b = MyClassObject1.Equals(MyClassObject2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.