This is straight forward in C#. If you have used TryParse() function then you already know the answer.
using System;
namespace Demo
{
class Program
{
static void Main()
{
Console.WriteLine("Please type your input and press Enter key");
string strInput = Console.ReadLine();
int result = 0;
if (int.TryParse(strInput, out result))
{
Console.WriteLine("Your input {0} is a number", result);
}
else
{
Console.WriteLine("Your input {0} is NOT a number", strInput);
}
}
}
}


0 comments:
Post a Comment
Note: only a member of this blog may post a comment.