Char Structure

char Structure represents a Unicode character.

char aliases the System.Char struct.

You can call the methods from char or from System.Char.

The Char structure has methods to compare char objects, convert the char object to an another type, and determine the Unicode category of a Char object.

The following code shows some of the basic methods from Char structure.


using System;

public class Test{
  public static void Main() {
    char chA = 'A';
    char ch1 = '1';
    string str = "java2s.com"; 

    Console.WriteLine(chA.CompareTo('B'));      
    Console.WriteLine(chA.Equals('A'));        
    Console.WriteLine(Char.GetNumericValue(ch1));  
    Console.WriteLine(Char.IsControl('\t'));    
    Console.WriteLine(Char.IsDigit(ch1));      
    Console.WriteLine(Char.IsLetter(','));      
    Console.WriteLine(Char.IsLower('u'));      
    Console.WriteLine(Char.IsNumber(ch1));      
    Console.WriteLine(Char.IsPunctuation('.'));  
    Console.WriteLine(Char.IsSeparator(str, 4));
    Console.WriteLine(Char.IsSymbol('+'));      
    Console.WriteLine(Char.IsWhiteSpace(str, 4));  
    Console.WriteLine(Char.Parse("S"));        
    Console.WriteLine(Char.ToLower('M'));      
    Console.WriteLine('x'.ToString());        
  }
}

The output:


-1
True
1
True
True
False
True
True
True
False
True
False
S
m
x
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.