Friday, 27 September 2013

type of input cSharp

type of input cSharp

actually I am trying to write small program that read input from user to
decide whether is it intger or not.
object x=Console.ReadLine();
check(x);
static void check(object x)
{
if (x.GetType() == typeof(int))
Console.WriteLine("int");
else
Console.WriteLine("not int");
}

No comments:

Post a Comment