- bool b = "true".ConvertTo<bool>();
- DateTime d1 = " 01:23:45 ".ConvertTo<DateTime>();
- Point p = "100,25".ConvertTo<Point>();
- //convert, but use specific culture.
- //in this case the comma is used as a decimal seperator
- Double d = "1.234,567".ConvertTo<double>("NL")
- //provide a default value, if conversion fails
- Guid g = "i'm not a guid".ConvertTo<Guid>(Guid.Empty);
- //该片段来自于http://www.codesnippet.cn/detail/180120131755.html
来源: http://www.codesnippet.cn/detail/180120131755.html