string str = "ABC123"; if (Regex.IsMatch(str, "^[a-zA-Z0-9]*$")) { Console.WriteLine("Alphanumeric String"); } else { Console.WriteLine("Non-Alphanumeric String"); }