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

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

上一篇:空与非空 EMPTY_LOB和NULL的区别


下一篇:delphi架构