Showing posts with label Data type. Show all posts
Showing posts with label Data type. Show all posts

Data type in C sharp

Integer Type

Decimal or Float Type

Boolean Type

Character Type

Base Type


  • All C# data type once after compile will be consumed into CIL type.
  • short ,int, long and sbyte datatype can store signed integer value. Where as byte, ushort , uint,ulong datatype can be store only unsigned integer value.
  • The size of char type has been increased to 2 bytes for providing support for Unicode character that is character other than English language .As we are aware that every English language character is associated with a numeric value known as ASCII which is converted into binary value for storing in the memory, Same as this every other language character are also associated with a numeric representation or value known as Unicode which converted into binary for storing in the memory.
  • String is a variable length data type and its size varies depending upon the value we assigned to it.
  • Object type is the parent of all the other data type capable of storing any type of value in it and moreover this is also a variable length data type only.


Why We need to create data type?

Let's talk about the data type. Why We need to create data type?

Data type cannot be consume directly because a data type does not have any memory for storing a value so, to consume a data type first we need to create the copy of type for which the memory is allocated . Just look the below example you will get to know what I mean.

The rule data type cannot be consumed directly this applies to both predefined as well as user defined type also So, if we want to consume our data type first we need to create the copy of them

Note*:-Generally copy of simple type (int) are known as variables whereas copy of complex type (Structure, Class) are known as Instances.