char case
In this chapter you will learn:
Change case for char value
using System; /* j a v a 2 s. 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.IsLower(str[i]))
Console.Write(" lowercase");
if(Char.IsUpper(str[i]))
Console.Write(" uppercase");
Console.WriteLine();
}
}
}
The code above generates the following result.
To upper case
using System; //from ja v a 2 s.co m
class MainClass {
public static void Main() {
string str = "This is a test. $23";
Console.WriteLine("Original: " + str);
// .
string newstr = "";
for(int i=0; i < str.Length; i++)
newstr += Char.ToUpper(str[i]);
Console.WriteLine("Uppercased: " + newstr);
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter: