I currently have the following code:
public enum FieldType
{
Int,
Year,
String,
DateTime
}
public enum DataType
{
Int,
String,
DateTime
}
I would like to have an extension method for each so that I can do something like this:
FieldType fType = FieldType.Year;
DataType dType = DataType.Int;
fType.Equals(dType); //If fType is an Int/Year, and dType is an Int it should return true
dType.Equals(fType); //If dType is an Int, and fType is an Int/Year it should be true
Is there a way to create a .Equals extension, so that this will work out?
As Jon said, reusing a framework’s method name is not a very good idea.
But you could easily do something like that :
or even better :