首页 > Windows开发 > 详细

【你吐吧c#每日学习】11.10 C# Data Type conversion

时间:2014-11-10 21:30:41      阅读:295      评论:0      收藏:0      [点我收藏+]

implicit

explicit

float f=12123456.213F

 

int a = Convert.ToInt32(f); //throw exception or

int a = (int)f; // not throw exception nut got an overflow value

 

parse and tryparse

string to other datatype

string a="100fh";

int num=int.Parse(a); //throw exception

int result=0;

bool isNum=int.TryParse(num,out result);

if(isNum){ Console.WriteLine(result);

}else{

Console.WriteLine("Invalid")}

【你吐吧c#每日学习】11.10 C# Data Type conversion

原文:http://www.cnblogs.com/jin-wen-xin/p/4087879.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!