In C#, built-in types are the primitive data types that the C# language provides out-of-the-box. They are really just aliases for .NET Framework types in the System namespace, but the C# keywords make them easier to use.


πŸ“Œ 1. Categories of Built-in Types

Integral Types

  • Whole numbers (signed and unsigned).
C# Keyword.NET TypeSizeRange
sbyteSystem.SByte8-bit-128 to 127
byteSystem.Byte8-bit0 to 255
shortSystem.Int1616-bit-32,768 to 32,767
ushortSystem.UInt1616-bit0 to 65,535
intSystem.Int3232-bit-2,147,483,648 to 2,147,483,647
uintSystem.UInt3232-bit0 to 4,294,967,295
longSystem.Int6464-bit-9.22e18 to 9.22e18
ulongSystem.UInt6464-bit0 to 1.84e19
charSystem.Char16-bitSingle Unicode character

Floating-point & Decimal Types

  • For real numbers and precise decimal calculations.
C# Keyword.NET TypeSizeRange / Precision
floatSystem.Single32-bit~7 digits of precision
doubleSystem.Double64-bit~15–16 digits of precision
decimalSystem.Decimal128-bit28–29 significant digits (great for money)

Other Primitive Types

C# Keyword.NET TypeDescription
boolSystem.BooleanRepresents true or false.
stringSystem.StringImmutable sequence of characters.
objectSystem.ObjectBase type for all types in C#.
dynamicSystem.ObjectRuntime-typed object (late binding).

Special Types

C# Keyword.NET TypeDescription
voidN/ARepresents no return value (used in methods).
varCompiler-inferredType inferred at compile time.
nullLiteralRepresents β€œno value” for reference types.

πŸ“Œ 2. Example Usage

class Program
{
    static void Main()
    {
        int age = 25;
        double pi = 3.14159;
        decimal money = 19.99m;
        char grade = 'A';
        bool isActive = true;
        string name = "Alice";
 
        Console.WriteLine($"{name}, {age} years old, Grade: {grade}, Active: {isActive}, Balance: {money}, Pi: {pi}");
    }
}

πŸ“Œ 3. Key Notes

  • Aliases vs .NET types:
    int ↔ System.Int32, string ↔ System.String.
    Both are the same, but C# developers almost always use the keyword.

  • Value types vs Reference types:

    • Value types: numbers, bool, struct, enum β†’ stored on the stack.

    • Reference types: string, object, dynamic, arrays, classes β†’ stored on the heap.


βœ… Summary:

  • Built-in types = C# keywords (aliases) for System types.

  • Categories: integral, floating-point, decimal, boolean, char, string, object, dynamic, void.

  • They’re the foundation of all data handling in C#.