using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestStringToNum
{
class Program
{
static void Main(string[] args)
{
String str = "15.23";
int i = 2;
float f = 1.2f;
Double du = 0.33;
Type tDouble = du.GetType();
Type tInt = i.GetType();
Type tFloat = f.GetType();
try
{
du = Double.Parse(str);
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
try
{
i = int.Parse(str);
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
try
{
f = float.Parse(str);
}
catch(Exception e)
{
Console.WriteLine(e.Message.ToString());
}
}
}
}