C# {Integral Types}

firdavs090

firdavs090

Posted on July 31, 2024

C# {Integral Types}

Integral Types:

1)byte: 8-bit unsigned integer (0 to 255)
2)sbyte: 8-bit signed integer (-128 to 127)
3)short: 16-bit signed integer (-32,768 to 32,767)
4)ushort: 16-bit unsigned integer (0 to 65,535)
5)int: 32-bit signed integer (-2,147,483,648 to 2,147,483,647)
6)uint: 32-bit unsigned integer (0 to 4,294,967,295)
7)long: 64-bit signed integer (-9,223,372,036,

using System;

class Program
{
    static void Main()
    {
        // byte: 8-bit unsigned integer (0 to 255)
        byte myByte = 255;
        Console.WriteLine("byte: " + myByte);

        // sbyte: 8-bit signed integer (-128 to 127)
        sbyte mySByte = -128;
        Console.WriteLine("sbyte: " + mySByte);

        // short: 16-bit signed integer (-32,768 to 32,767)
        short myShort = -32768;
        Console.WriteLine("short: " + myShort);

        // ushort: 16-bit unsigned integer (0 to 65,535)
        ushort myUShort = 65535;
        Console.WriteLine("ushort: " + myUShort);

        // int: 32-bit signed integer (-2,147,483,648 to 2,147,483,647)
        int myInt = -2147483648;
        Console.WriteLine("int: " + myInt);

        // uint: 32-bit unsigned integer (0 to 4,294,967,295)
        uint myUInt = 4294967295;
        Console.WriteLine("uint: " + myUInt);

        // long: 64-bit signed integer (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
        long myLong = -9223372036854775808;
        Console.WriteLine("long: " + myLong);

        // ulong: 64-bit unsigned integer (0 to 18,446,744,073,709,551,615)
        ulong myULong = 18446744073709551615;
        Console.WriteLine("ulong: " + myULong);
    }

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
firdavs090
firdavs090

Posted on July 31, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

C# {Integral Types}
dotnet C# {Integral Types}

July 31, 2024