关于C#中Convert.ToInt32()是干什么用的

并非每个对象都可以直接转换为int。例如,以下内容将无法编译:

string Maomao = "100";

int i = (int)Maomao;

因为string无法隐式转换为int。 如果必须要做就这样写:


string Maomao = "100";

int i = Convert.ToInt32(Maomao); 

猜你喜欢

转载自www.cnblogs.com/maomaodesu/p/11393355.html