using System; namespace Example76 { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Console.Write("Input a string: "); string s = Console.ReadLine(); Console.WriteLine("Is {0} a variable name? {1}", s, IsVariable(s)); } static bool IsVariable(string s) { if (s.Length == 0) return false; else if (Char.IsLetter(s[0])) return IsVariable2(s.Remove(0, 1)); else return false; } static bool IsVariable2(string s) { if (s.Length == 0) return true; else if (Char.IsLetter(s[0]) || Char.IsDigit(s[0])) return IsVariable2(s.Remove(0, 1)); else return false; } } }