March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System;
namespace Samples
{
public class FormatExceptionSample
{
public static void Main()
{
try
{
string s = "12.34";
int i = Convert.ToInt32(s);
}
catch(FormatException e)
{
Console.WriteLine("Exception: {0}", e);
}
}
}
}
Exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Convert.ToInt32(String value) at Samples.FormatExceptionSample.Main() in C:\Books\BCL\Samples\System\ FormatException\FormatException.cs:line 12
Read now
Unlock full access