为什么这些会返回 true
:
TypeDescriptor.GetConverter(typeof(double)).CanConvertTo(typeof(double));
TypeDescriptor.GetConverter(typeof(int)).CanConvertTo(typeof(int));
当这些返回 false
时?
TypeDescriptor.GetConverter(typeof(decimal)).CanConvertTo(typeof(decimal));
TypeDescriptor.GetConverter(typeof(bool)).CanConvertTo(typeof(bool));
考虑到 GetConverter 返回的所有转换器都只能将类型转换为字符串并从字符串转换回类型:
我正在使用 .NET Framework 4.5.2。