码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2019-08-22 13:20:23      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:编译   隐式   code   string   int   隐式转换   对象   str   ring   

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

string Maomao = "100";

int i = (int)Maomao;

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


string Maomao = "100";

int i = Convert.ToInt32(Maomao); 

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

标签:编译   隐式   code   string   int   隐式转换   对象   str   ring   

原文地址:https://www.cnblogs.com/maomaodesu/p/11393355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!