我目前有以下代码:
public enum FieldType
{
Int,
Year,
String,
DateTime
}
public enum DataType
{
Int,
String,
DateTime
}
Run Code Online (Sandbox Code Playgroud)
我想为每个方法都有一个扩展方法,这样我就可以这样做:
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
Run Code Online (Sandbox Code Playgroud)
有没有办法创建一个.Equals扩展,这样就可以了?
c# ×1