CSharp examples for System:String Number
Checks if string has only numbers
using System.Text.RegularExpressions; using System.Text; using System.Globalization; using System.Collections.Generic; using System;/* ww w. j a v a 2s . co m*/ public class Main{ //Checks if string has only numbers //12453 -> True //234d3 -> False public static bool IsNumeric(string input) { for (int i = 0; i < input.Length; i++) { if (!(Convert.ToInt32(input[i]) >= 48 && Convert.ToInt32(input[i]) <= 57)) { //Not integer value return false; } } return true; } }