Try a regular expression. Depending on your meaning
of all caps, the following may give you what you want:
Running the following:
-----------------------------------------------------------------
using System;
using System.Text.RegularExpressions;
class Test {
public static bool ValidateAllCaps(string inString)
{
Regex r = new Regex("^[A-Z ]+$"); // Note the space between Z & ]
return r.IsMatch(inString);
}
public static void Main(string[] args)
{
foreach (string s in args)
{
Console.WriteLine("The string '{0}' {1} all caps",
s, (Test.ValidateAllCaps(s)? "is": "is not"));
}
}
}
-----------------------------------------------------------------
gives:
D:\_csharp\regex>allcaps "MY NAME IS" "My Name is" 1234 "MY NAME IS 6"
The string 'MY NAME IS' is all caps
The string 'My Name is' is not all caps
The string '1234' is not all caps
The string 'MY NAME IS 6' is not all caps
There's lots of info about regular expressions on the internet. For example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemtextregularexpressionsregexclasstopic.asp
Garrett