Is char a letter
In this chapter you will learn:
Char.IsLetter
The following code uses a for loop to check each character in a string.
using System; // j a va 2s .c o m
class MainClass {
public static void Main() {
string str = "This is a test. $23";
int i;
for(i=0; i < str.Length; i++) {
Console.Write(str[i] + " is");
if(Char.IsLetter(str[i]))
Console.Write(" letter");
Console.WriteLine();
}
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter: