///时间类型
///
DateTime date = new DateTime(2007,3,8,10,10,30);//实例一个时间对像,参数表示年,月,日,时,分,秒
string strDate = date.ToString();//将时间类型值转换为字符串
//DateTime date1 = DateTime.Parse(strDate);//将字符串转为时间类型
Console.WriteLine("时间类型转为字符串:\r\n"+strDate);
///整型值
///
//长整型
long x = 12345;
string str = x.ToString();//长整型转为字符串
//long y = Int64.Parse(str);//字符串转为长整型
Console.WriteLine("长整型转为字符串: " + str);
//整型
int x1 = 12345;
string str1 = x1.ToString();//整型转为字符串
//int y1 = Int32.Parse(str1);//字符串转为整型
Console.WriteLine("整型转为字符串: " + str1);
//短整型
Int16 x2 = 12345;
string str2 = x2.ToString();//整型转为字符串
//Int16 y2 = Int16.Parse(str2);//字符串转为整型
Console.WriteLine("短整型转为字符串: " + str2);
///double转float值
///double不能隐式地转换为float值
///必须显示地转换
float x3 = (float)123.12;//double显示转换为float值
string strFloat = x3.ToString();
//float y3 = float.Parse("123.3");
Console.WriteLine("float转为字符串:"+ strFloat);
double bbb = double.Parse("123.12");
Console.WriteLine("double类型:"+bbb);
///IPAddress值
///
IPAddress ip = new IPAddress(124464);
string strIP = ip.ToString();
Console.WriteLine(strIP);
IPAddress ip1 = IPAddress.Parse("192.168.0.1");
Console.WriteLine(ip1);
///
DateTime date = new DateTime(2007,3,8,10,10,30);//实例一个时间对像,参数表示年,月,日,时,分,秒
string strDate = date.ToString();//将时间类型值转换为字符串
//DateTime date1 = DateTime.Parse(strDate);//将字符串转为时间类型
Console.WriteLine("时间类型转为字符串:\r\n"+strDate);
///整型值
///
//长整型
long x = 12345;
string str = x.ToString();//长整型转为字符串
//long y = Int64.Parse(str);//字符串转为长整型
Console.WriteLine("长整型转为字符串: " + str);
//整型
int x1 = 12345;
string str1 = x1.ToString();//整型转为字符串
//int y1 = Int32.Parse(str1);//字符串转为整型
Console.WriteLine("整型转为字符串: " + str1);
//短整型
Int16 x2 = 12345;
string str2 = x2.ToString();//整型转为字符串
//Int16 y2 = Int16.Parse(str2);//字符串转为整型
Console.WriteLine("短整型转为字符串: " + str2);
///double转float值
///double不能隐式地转换为float值
///必须显示地转换
float x3 = (float)123.12;//double显示转换为float值
string strFloat = x3.ToString();
//float y3 = float.Parse("123.3");
Console.WriteLine("float转为字符串:"+ strFloat);
double bbb = double.Parse("123.12");
Console.WriteLine("double类型:"+bbb);
///IPAddress值
///
IPAddress ip = new IPAddress(124464);
string strIP = ip.ToString();
Console.WriteLine(strIP);
IPAddress ip1 = IPAddress.Parse("192.168.0.1");
Console.WriteLine(ip1);