char case

In this chapter you will learn:

  1. How to change case for C# char value
  2. Convert character to upper case

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:

  1. Compares to another Char
Home » C# Tutorial » bool, char
bool
bool and if statement
bool value to string
Parse string to bool value
char type
char escape sequence
char case
Compare char value
char min/max value
Is char a digit
Is char a letter
Is char a symbol
Is char a Separator
Is char white space
Convert to char
UTF-16 Character