Articles → .NET → Data Types In C#

Data Types In C#










Signed And Unsigned Numbers









Boolean




Boolean x = false;
bool y = false;



Byte And Sbyte


  1. In computers, information is stored in the form of bit.
  2. A bit is the smallest unit of information.
  3. A bit is a single numeric value that is either ‘0’ or ‘1’.




  1. A Byte is a sequence of bits.
  2. 8 bits makes 1 byte.






Data TypeMinimum ValueMaximum Value
byte0255
sbyte-128127




byte unsignedByte = 240;
sbyte signedByte = -120;



Char














char x = 'A'; // Single character
char y = '\u0041'; // Unicode of 'A'




Data TypeMinimum ValueMaximum Value
char'\u0000''\uffff'





Int, Long, Short, Uint, Ulong And Ushort




Data TypeMinimum ValueMaximum Value
int-2,147,483,6482,147,483,647
long-923,372,036,854,775,8089,223,372,036,854,775,807
short-32,76832,767
uint04,294,967,295
ulong018,446,744,073,709,551,615
ushort065535


int a;
long b;
short c;
uint d;
ulong e;
ushort f;



Decimal, Double And Float




Data TypeSizePrecision
float32-bit7 significant digits
double64-bit15-16 significant digits
decimal128-bit28-29 significant digits




  1. All non-zero digits are significant digits.
  2. Zero among the non-zero digits is significant digits.
  3. All leading zeros before decimal are non-significant.
  4. All zeros after decimal are significant digits.


  1. 12 contain 2 significant digits.
  2. 7000 contain 1 significant digit
  3. 4009 contain 4 significant digits.
  4. 4.20 contain 3 significant digits.
decimal a = 0.0M;
float b = 0.0F;
double c = 0.0;



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, May 5, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250