vijay

welcome Netizen

welcome Netizen
Hi folks this site Share Basic Knowledge in .NET, DotNet, C#,DOT NET CODE, ASP.NET, VB.NET, DOT NET TRICKS,Dotnetcode,Android and Latest Technology Articles in VB,Android and ASP.NET

Friday, December 28, 2012

Data Types in C#


Introduction
In C# every variable is associated with a data type. Data types specify the size and type of the values that can be stored.
The types in C# are divided into two types
1. Value types
2. Reference types
Both value types and reference types are differ in characteristic
Difference between value types and reference types

Value type:
Value type are stored on the stack and when a value of a variable is assigned to another variable, the value is actually copied i.e. two identical copies of the value are available in memory
Normally the value types are grouped in two categories...
User Defined types:
·         Enumeration
·         structures
Predefined types
·         Integers
·         Real Number
·         Boolean
·         Characters
Eg:
int m=10;
int n;
N=m; Here the value are actually copied.
Reference Type:
Reference type are stored on the heap and when a value of a variable is assigned to another variable, only the reference is copied, actual value remains in the same memory location i.e. two reference to a single value
  
 Reference types also divided into two groups
·         User Defined types
·         Predefined types
User defined types:
·         Classes
·         String
·         Delegates
·         Array
Predefined types
·         Object type
·         String type
Eg:
Object  m=10;
Object n;
N=m; Here only the reference has been copied, the value are stored same location,any changes on m also affect the changes on n.

If you like this article share this information with your friends
Post your comments here..

0 comments:

Post a Comment