When a structure is
instantiated using the new keyword, a constructor (no-argument or custom, if
provided) is called which initializes the fields in the structure. When a
structure is instantiated without using the new keyword, no constructor is
called. Hence, one has to explicitly initialize all the fields of the structure
before using it when instantiated without the new keyword.
Encapsulation
Wrapping up of data
and function into a single unit is known as Encapsulation.
Properties
Attribute of object is
called properties. Eg1:- A car has color as property.
Eg2:
private string m_Color;;
public string Color
{
get
get
{
return m_Color;
}
set
{
m_Color = value;
}
}
Car Maruti = new
Car();
Maruti.Color= “White”;
Console.Write(Maruti.Color);
No comments:
Post a Comment