Search This Blog

Tuesday, December 30, 2008

What is the difference between Readonly and constant in C#

The only difference between both is in their intialization.
if u declare a constant field you must set the value before ntializing object.
but readonly you can declare it in constructor.
both cannot be altered once declared.

What is Encapsulation and Abstraction

Encapsulation:
Encapsulation is nothing but grouping related data .exaple in Patient Class we will write all the functionality related to Patient.i.e all patient related data i am putting in one place called Patient Class This is called Encapsulatin.
Abstraction:
in Patient class i might be having public,private,internal methods,properties etc..
if anybody creates object to Patient class they only get either Public and or internal methods or prperties not private methods,properties or fields.so patient class is expsing only few methods or properties as public or internal methds or properties while not showing private things this is called abstraction.