CSharp examples for System:String Number
Is Alpha Numeric, Checks if string is numbers and letters
using System.Text.RegularExpressions; using System.Text; using System.Globalization; using System.Collections.Generic; using System;//from w ww .j a va 2s .c om public class Main{ //Checks if string is numbers and letters //Test1254 -> True //$chool! -> False public static bool IsAlphaNumeric(string input) { char currentLetter; for (int i = 0; i < input.Length; i++) { currentLetter = input[i]; if (!(Convert.ToInt32(currentLetter) >= 48 && Convert.ToInt32(currentLetter) <= 57) && !(Convert.ToInt32(currentLetter) >= 65 && Convert.ToInt32(currentLetter) <= 90) && !(Convert.ToInt32(currentLetter) >= 97 && Convert.ToInt32(currentLetter) <= 122)) { //Not a number or a letter return false; } } return true; } }