日期:2014-05-17  浏览次数:20693 次

关于枚举向字符串的转换
看一段代码的时候,发现一个方法
public string Get(Traffic t)
{
    return TypeDescriptor.GetConverter(typeof(Traffic)).ConvertToInvariantString(t);
}

Traffic是一个枚举,包括Bus, Car.

ConvertToInvariantString方法是转换为区域性不变的字符串。 这是什么意思?
直接.ToString(), 枚举不也可以转为字符串吗?

------解决方案--------------------
http://msdn.microsoft.com/zh-cn/library/ms235309%28v=VS.90%29.aspx
------解决方案--------------------
refer:http://msdn.microsoft.com/zh-cn/library/vstudio/system.componentmodel.typeconverter.converttoinvariantstring.aspx