Simple and Easy Explaination about C# Data Types

In this article i will try to explain Data Types,Type and Data Types in easy and simple words.

What is Data Type :

Data Type is nothing but storing the values in a particular variable and that variable describe the type of the value. The value can be any form like Numeric Value, Floating Values, Boolean Values, Char and String Values and so on.

Types of Data Type :

  1. Numerical Data Types
  2. Floating Point Data Types
  3. Character Related Data Type
  4. Logical Data Types
  5. General Data Types

1. Numerical Data Types

Numerical Data Types will be 2 types

  • Signed Numerical Data Type
  • Unsigned Numerical Data Type
Signed Numerical Data Type

Signed Numerical data type contain only Positive and Negative Values and its classified into 4 types.

  1. sbyte
    s-stand for signed
    sbyte predefined size is 1 byte = 1*8 = 8 bits
    base type of sbyte : System.SByte
    sbyte accomodiate the memory min size : -128 and max size : 127
  2. short
    s-stand for signed
    short predefined size is 2 byte = 2*8 = 16 bits
    base type of short : System.Int16
    short accomodiate the memory min size : -32768 and max size : 32767
  3. int
    int predefined size is 4 byte = 4*8 = 32 bits
    base type of int : System.Int32
    int accomodiate the memory min size : -2147483648 and max size : 2147483647
  4. long
    long predefined size is 8 byte = 8*8 = 64 bits
    base type of long : System.Int64
    long accomodiate the memory min size : -9223372036854775808 and max size : 9223372036854775807
Unsigned Numerical Data Type

Unsigned Numerical data type contain only Positive Values only and its classified into 4 types.

  1. byte
    byte predefined size is 1 byte = 1*8 = 8 bits
    base type of byte : System.Byte
    byte accomodiate the memory min size : 0 and max size : 255
  2. ushort
    u-stand for unsigned
    ushort predefined size is 2 byte = 2*8 = 16 bits
    base type of ushort : System.UInt16
    ushort accomodiate the memory min size : 0 and max size : 65535
  3. uint
    uint predefined size is 4 byte = 4*8 = 32 bits
    base type of uint : System.UInt32
    uint accomodiate the memory min size : 0 and max size : 4294967295
  4. ulong
    ulong predefined size is 8 byte = 8*8 = 64 bits
    base type of ulong : System.UInt64
    ulong accomodiate the memory min size : 0 and max size : 18446744073709551615
Q.) Difference between Signed and UnSigned Numerical Data Types

→ Signed Numerical Data Type contain only Positive and Negitive values

→ UnSigned Numerical Data Type contain only Positive values only

2. Floating Point Data Types

→ A number which is having fraction part is called Floating Point Data Type

→ By default Floating Point Data Types are Signed

→ we do not have any Unsigned Floating Point Data Types

→ According to the size floating point data types are classified into 3 types

  1. float
    float predefined size is 4 byte = 4*8 = 32 bits
    base type of float : System.Single
  2. double
    double predefined size is 8 byte = 8*8 = 64 bits
    base type of double : System.Double
  3. decimal
    decimal predefined size is 16 byte = 16*8 = 128 bits
    base type of decimal : System.Decimal

3. Char Data Type

  1. char
    char predefined size is 2 byte = 2*8 = 16 bits
    base type of char : System.Char

4. Logical Data Type

  1. bool
    bool predefined size is 1 bits
    base type of bool : System.Boolean
    true will be stored into memory as binary 1
    false will be stored into memory as binary 0

5. General Data Type

  1. string
    general data type will not have predefined size
    base type of string : System.String
  2. object
    base type of object : System.Object

Post a Comment

0 Comments