只是好奇:
这些线投掷Invalid Cast Exception:
Unable to cast object of type 'System.Double' to type 'System.String'.
Object obj = new object();
obj = 20.09089;
string value = (string)obj;
Run Code Online (Sandbox Code Playgroud)
我obj从a 获得了价值library.
如何简单转换为string我们不知道object枚举时的类型?
这就是.net中的每个对象都有ToString()方法(继承自Object)的原因
string str = (obj == null) ? string.Empty : obj.ToString();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
226 次 |
| 最近记录: |