C# Data Types

dtype_logo-300x110 In this chapter you will learn:

  • Different types of C# data types, their sizes and storing capacities
  • Difference between value types data types and reference type data types

C# is a strongly typed language. It means, that you cannot use variable without data types. Data types tell the compiler that which type of data is used for processing. Such as if you want to work with string value then you will have to assign string type variable to work with. C# provides two types of data types: Value types and Reference types.

A Value type data type stores copy of the value whereas the Reference type data types stores the address of the value. C sharp provides great range of predefined data types but it also gives the way to create user defined data types.


A complete detail of C# data types are mentioned below:

Value Types:

Data Types Size Values
sbyte 8 bit -128 to 127
byte 8 bit 0 to 255
short 16 bit -32,768 to 32,767
ushort 16 bit 0 to 65,535
int 32 bit -2,147,483,648 to 2,147,483,647
uint 32 bit 0 to 4,294,967,295
long 64 bit -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong 64 bit 0 to 18,446,744,073,709,551,615
char 16 bit 0 to 65535
float 32 bit -1.5 x 1045 to 3.4 x 1038
double 64 bit -5 x 10324 to 1.7 x 10308
decimal 128 bit -1028 to 7.9 x 1028
bool True or false

 

Reference Types:

 

Data Types Size Values
string Variable length 0-2 billion Unicode characters
object

Summary

In this chapter you learned about different types of data types that C# uses. You also know about value type data types and reference type data types. In next chapter you will learn how to use all these data types in a program to creating a variable in C#.



2 thoughts on “C# Data Types”

  1. Hi , This is Shashank Kolpuru , One Small Suggestion Your Website is Awsomee for Beginners , I Request you to Update the Whole C# Programming ASAP , Please 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *