← Back to C# Course | Chapter 2: Variables & Types | Lesson 4 of 7

char Type क्या है

एक char बिल्कुल एक letter, digit, या symbol रखता है, जैसे किसी word game की एक tile। इसे single quotes से लिखा जाता है।

In this page:

  1. The char Type
Syntax
csharp
char variableName = 'A';
int code = (int)variableName;
bool isDigit = char.IsDigit(variableName);

The char Type

एक char एक single UTF-16 character को represent करता है और single quotes से लिखा जाता है, जैसे A। Characters को compare, उनके underlying numeric code point में cast, और strings में combine किया जा सकता है। Double quotes string के लिए reserved हैं, char के लिए नहीं।

Note: किसी char को int में cast करने पर आपको उसका Unicode code point मिलता है।

उदाहरण: The char Type

markup
using System;

class Program
{
    static void Main(string[] args)
    {
        char letter = 'A';
        char digit = '7';

        Console.WriteLine(letter);
        Console.WriteLine((int)letter);
        Console.WriteLine(char.IsDigit(digit));
    }
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. किसी char के लिए double quotes का उपयोग करना, जैसे char c = "A";, जबकि char को single quotes A चाहिए।
  2. यह उम्मीद करना कि a + 1 एक char होगा, जबकि result एक int है और इसे char में cast चाहिए।
  3. ab जैसे किसी char literal में एक से ज़्यादा characters डालने की कोशिश करना।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.