try
{
Response.Write("ToDecimal:"+Convert.ToDecimal("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToDouble:"+Convert.ToDouble("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt16:"+Convert.ToInt16("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt32:"+Convert.ToInt32("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt64:"+Convert.ToInt64("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToUInt16:"+Convert.ToUInt16("1.11").ToString()+"<br>");
}
catch
{}打印结果:
ToDecimal:1.11
ToDouble:1.11整数怎么会报错?????
{
Response.Write("ToDecimal:"+Convert.ToDecimal("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToDouble:"+Convert.ToDouble("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt16:"+Convert.ToInt16("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt32:"+Convert.ToInt32("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToInt64:"+Convert.ToInt64("1.11").ToString()+"<br>");
}
catch
{}
try
{
Response.Write("ToUInt16:"+Convert.ToUInt16("1.11").ToString()+"<br>");
}
catch
{}打印结果:
ToDecimal:1.11
ToDouble:1.11整数怎么会报错?????
float s1;
string sb="";
sb=string.Format(sb,s1);
int.Parse(sb);
你这样试试, 应当行!!!
float s1;
string sb="{0}";
sb=string.Format(sb,s1);
int.Parse(sb);
float s1;
string sb="";
s1=xxx.xx;
sb=string.Format(sb,s1);
int.Parse(sb);
try
{
Console.WriteLine("ToInt32:" + Convert.ToInt32(1.11).ToString());
Console.ReadLine();
}
catch
{
}