【发布时间】:2011-11-15 15:26:31
【问题描述】:
可能重复:
What is the difference between the following casts in c#?
在处理 C# 时,她正在做类型转换,那时我有一个疑问:-
“as vs. (int)/(string)/... Soon”的对象类型转换有什么区别?
示例:
int a = (int) value;
VS.
int a = value as int;
string a = (string) value;
VS.
string a = value as string;
很快……
谁能详细解释一下?
提前致谢。
【问题讨论】:
-
查看此链接 [Casting vs using the 'as' keyword in CLR][1] [1]: stackoverflow.com/questions/496096/…
-
感谢大家提供的信息。