All the data types in C# code example

Example 1: c# data types

// -------DATA TYPES ------- //

sbyte myNum = 1;             // Smallest range of integer numbers
uint myNum = 3;				 // Only positive integer numbers
short myNum = 4;             // Short range of integer numbers
int myNum = 5;               // Integer (whole numbers)
long myNum = 10;             // Biggest range of integer numbers 
float myFloat = 1.2f;        // Smallest range of floating point numbers
double myDoubleNum = 5.99;   // Big range of floating point numbers
decimal myDecimalNum = 2.2M; // Biggest precision in floating point numbers
char myLetter = 'D';         // Character
string myString = "Hello!"   // Strings
bool myBool = true;          // Boolean

Example 2: c# data types

using System;
class BoxingExample
{
    static void Main()
    {
        int i = 123;
        object o = i;    // Boxing
        int j = (int)o;  // Unboxing
    }
}

Tags:

C Example