Wednesday, 8 August 2012

Struct in C#

A Struct is similar to the class with the follwing key differences

1. A Struct is a value type where as a class is a reference type
2. A Struct does not support Inheritance
3. A Struct can't have explicit parameter less constructors

Thursday, 2 August 2012

Difference between readonly and constant

1. readonly and constant are two keywords
2. If you are using readonly keyword then the variable value can be assigned at the time of declaration otherwise in the constructor
3. where as in case of constant the variable value can only be assigned at the time of declaration not in the constructor
4.readonly variable can be accessed by the instance of a class where as in case of constant it is only accessed by the class name not by the instance of a class