Just a little snippet to check if a string contains only letters.
Check if a string contains only letters
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string MyString = "A @string & and 2.";
Console.WriteLine(MyString);
for (int charpos = 0; charpos < MyString.Length; charpos++)
{
Console.WriteLine(Char.IsLetter(MyString, charpos));
}
//Keep the console on screen
Console.WriteLine("Press any key to quit.");
Console.ReadKey();
}
}
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.