Skip to content

CSharp Keyword char

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

C#: char

Довідник C# · Практичне керівництво

Один 16-бітовий кодовий елемент UTF-16. Символ записують в одинарних лапках; один Unicode-символ може складатися з кількох елементів.

Простий приклад (Example.cs)

Збережіть цей приклад окремо як Example.cs. Запускайте його незалежно від інших прикладів на сторінці.

Example.cs:

// PROJECT-EXAMPLE
char letter = 'A';
System.Console.WriteLine((int)letter);

Результат:

65

Синтаксис

char letter = 'A';

Приклад 1: базова форма

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        char letter = 'A';
        Console.WriteLine(char.ToLowerInvariant(letter));
        Console.WriteLine((int)letter);
    }
}

Приклад 2: інша практична форма

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        char[] letters = ['a', '7', 'Я'];
        foreach (char letter in letters) Console.WriteLine($"{letter}: {char.IsLetter(letter)}");
    }
}

Офіційне джерело: Microsoft Learn.

Clone this wiki locally