C# Type Checking Built In [Archive] - C Board

PDA

View Full Version : C# Type Checking Built In


Troll_King
01-02-2002, 06:48 PM
using System;

namespace PracticeConsoleCS
{
/// <summary>
/// Testing Type Safety
/// </summary>
class Class1
{
static void Main(string[] args)
{
Console.Write("Enter an integer: ");
int x = Convert.ToInt32(Console.ReadLine());
}
}
}


I only want a 32 bit integer and if the user enters a number that exceeds the type limit than C# throws an exception. This is great!