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

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

string Maomao = "100";

int i = (int)Maomao;

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


string Maomao = "100";

int i = Convert.ToInt32(Maomao); 
posted @ 2019-08-22 11:30  卯毛  阅读(14606)  评论(0编辑  收藏  举报