111,126
社区成员
发帖
与我相关
我的任务
分享
// 隐式转换
public static implicit operator AType(BType b)
{
...
}
BType b = ...
AType a = b;
// 显式转换
public static explicit operator AType(BType b)
{
...
}
BType b = ...
AType (BType)a = b;
// Convert.ChangeType
Double d = -2.345;
int i = (int)Convert.ChangeType(d, typeof(int));
// TypeConverter
Color c = Color.Red;
Console.WriteLine(TypeDescriptor.GetConverter(c).ConvertToString(c));