.NET Framework sürümünüz 2.0 ve üstü ise tryparse kullanarak kontrolü yapabilirsiniz. Altta küçük bir örnek gönderiyorum.
PHP- Kodu:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1. Değer");
string FirstValue = Console.ReadLine();
Console.WriteLine("2. Değer");
string SecondValue = Console.ReadLine();
int ParsedFirstValue;
int ParsedSecondValue;
if (int.TryParse(FirstValue, out ParsedFirstValue) && int.TryParse(SecondValue, out ParsedSecondValue))
{
Console.Write("Toplam : ");
Console.WriteLine((ParsedFirstValue + ParsedSecondValue).ToString());
}
else {
Console.WriteLine("Lütfen sayısal değerler giriniz.");
}
Console.ReadLine();
}
}
}