Home > C# > Difference between Class and Structure

Difference between Class and Structure

Classes are Reference types and Structures are Values types.

Classes are reference types, basically they will contain the address of an instance variables.

Class SimpleClass
Public int Value; 	

This the simple class am assigning value to Object to it.

Static Public void Main (string [] arg)
SimpleClass objSimpleClass1=new SimpleClass();
SimpleClass objSimpleClass2= new SimpeClass();


after in next step we change it to 10 in the object objSimpleClass2.  Since both object refer the same address, changes happened in the objSimpleClass2 or in last step that value will reflect in other object also.

Categories: C#
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: