1.转换者与被转换者之间有某些转换关系。
2.转化者与被转换者之间有继承关系
class FirstType { public string Name{get;set;} } class SecondType { public string Name{get;set;} public static explicit operator SecondType(FirstType fis) { SecondType second=new SecondType(Name= fis.Name); return second; } }
强制转化代码
FirstType first=new FirstType(Name="test"); SecondType second = (FirstType)first;