The Char Data type In C#

The Char Data type In C#

The Char Data type In C#:- The character or char data type defined within C# is used to hold a single Unicode character. Character variables hold a 16-bit number representing a letter, digit, symbol, or control character. They can also be considered as a numeric data type with similar properties to an unsigned short integer value.

 

The System.Char data type is used to hold a single, Unicode character.

 

char ch;

 

using System; 
using System.Text; 
  
namespace usingcsharp{ 
  
class test{ 
  
    static void Main(string[] args) 
    { 
        // char variable declaration 
        char ch = 'a'; 
  
        // to print the type of variable 
        Console.WriteLine("Type of ch: " + ch.GetType()); 
  
        // to print value 
        Console.WriteLine("ch: " + ch); 
  
        // to print size of a char 
        Console.WriteLine("Size of a char variable: " + sizeof(char));  
        
        Console.ReadLine(); 
    } 
} 
} 

 

2021-10-03