Data Types quick reference (prints to Console)

    0

    0

    reference

    Console.WriteLine($"({sizeof(decimal)} byte) decimal : {decimal.MinValue} to {decimal.MaxValue}");

    The code prints the following:

    Signed integral types:

    ( 2 byte) sbyte : -128 to 127 ( 4 byte) bool : false to true ( 8 byte) char : 'a' to 'z' ( 16 byte) short : -32768 to 32767 ( 32 byte) float : 0.0f to 3.14159 ( 64 byte) int : -2147483648 to 2147483647 ( 128 byte) double : 0.0 to 3.4 ( 256 byte) long : -9223372036854775808 to 9223372036854775807

    Unsigned integral types:

    ( 2 byte) byte : 0 to 255 ( 4 byte) ushort : 0 to 65535 ( 8 byte) uint : 0 to 4294967295

    Library: Reference

    // Prints to Console the byte size (memory footprint) and 'min & max' values of each datatype for quick reference
    Console.WriteLine("Signed integral types:");
    Console.WriteLine($"( {sizeof(sbyte)} byte) sbyte   : {sbyte.MinValue} to {sbyte.MaxValue}");
    Console.WriteLine($"( {sizeof(char)} byte) char    :  {char.MinValue} to {char.MaxValue}");
    Console.WriteLine($"( {sizeof(short)} byte) short   : {short.MinValue} to {short.MaxValue}");
    Console.WriteLine($"( {sizeof(float)} byte) float   : {float.MinValue} to {float.MaxValue}");
    Console.WriteLine($"( {sizeof(int)} byte) int     : {int.MinValue} to {int.MaxValue}");
    Console.WriteLine($"( {sizeof(double)} byte) double  : {double.MinValue} to {double.MaxValue}");
    Console.WriteLine($"( {sizeof(long)} byte) long    : {long.MinValue} to {long.MaxValue}");
    Console.WriteLine($"({sizeof(decimal)} byte) decimal : {decimal.MinValue} to {decimal.MaxValue}");
    
    Console.WriteLine("\nUnsigned integral types:");
    Console.WriteLine($"( {sizeof(bool)} byte) bool    : {bool.FalseString}(0) to {bool.TrueString}(1)");
    Console.WriteLine($"( {sizeof(byte)} byte) byte    : {byte.MinValue} to {byte.MaxValue}");
    Console.WriteLine($"( {sizeof(ushort)} byte) ushort  : {ushort.MinValue} to {ushort.MaxValue}");
    Console.WriteLine($"( {sizeof(uint)} byte) uint    : {uint.MinValue} to {uint.MaxValue}");
    Console.WriteLine($"( {sizeof(ulong)} byte) ulong   : {ulong.MinValue} to {ulong.MaxValue}");
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.