Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Phương thức Char.ConvertFromUtf32(Int32) trong C#

Phương thức Char.ConvertFromUtf32(Int32) trong C# chuyển đổi điểm mã Unicode (code point) được chỉ định thành chuỗi được mã hóa UTF-16.

Cú pháp

public static string ConvertFromUtf32(int utf32);

Tham số utf32 là điểm mã Unicode 21-bit.

Ví dụ 1

using System;
public class Demo
{
    public static void Main()
    {
        int utf = 0x0051;
        string str = Char.ConvertFromUtf32(utf);
        Console.WriteLine("Value = " + str);
    }
}

Đầu ra

Value = Q

Ví dụ 2

using System;
public class Demo
{
    public static void Main()
    {
        int utf = 0x0046;
        string str = Char.ConvertFromUtf32(utf);
        Console.WriteLine("Value = " + str);
    }
}

Đầu ra

Value = F