Convert string value to integer by using the int.TryParse
using System; public class MainClass { public static void Main() { int i; bool failure = int.TryParse("qwerty", out i); bool success = int.TryParse("123", out i); } }