0Pricing
C# Academy · Lesson

char, Unicode basics, simple parsing/formatting

Understand char (UTF-16 code unit), surrogate pairs for some characters, basic UTF-8 encoding/decoding, and simple number parsing/formatting.

Overview

Goal: Handle low-level text safely.

  • char is UTF-16
  • Some symbols use surrogate pairs
  • Encode/decode with UTF-8
  • Parse and format numbers

char basics

char is a 16-bit UTF-16 code unit; you can inspect category helpers like char.IsLetter.

using System;

public class Program
{
  public static void Main(string[] args)
  {
    char ch = 'A';
    Console.WriteLine("ch = " + ch);
    Console.WriteLine("UTF-16 code unit = " + (int)ch); // 65
    Console.WriteLine("IsLetter? " + char.IsLetter(ch));
    Console.WriteLine("ToLower = " + char.ToLower(ch));
  }
}

All lessons in this course

  1. Strings & Text: immutability, interpolation, verbatim, StringBuilder, comparison
  2. StringBuilder, comparison & culture notes
  3. char, Unicode basics, simple parsing/formatting
← Back to C# Academy