Object initialization ASP.net

Ratings:
(4)
Views:0
Banner-Img
  • Share this blog:

Object initialization

Object initializes are used to initialize or store the required data into the data field at a class when we create objects to the class. At the time of creating object only we use delimiters to initializes the data into object data fields like Emp obj=new Emp () {empid=10, ename=” Raju”, address=”hyd”, age=23};

Example with object initializes:

Name space CA sample
{
Class employee
{
Public int empid,age;
Public string ename, add;
}
Class example4
{
Employee obj=new employee () { empid=101,enames=”Raju”,add=”hyd”,age=23};
c.w.l (“employee details are:-”);
c.w.l (“Id is:-”obj.empid);
c.w.l (“Name is:-“obj.ename);
c.w.l (“Address is:-”obj.address);
c.w.l (“age is:-”obj.age);
   c.Read();
}
}
}

Inclined to build a profession as ASP.net Developer? Then here is the blog post on, explore ASP.net Training

Example of object initialize with Auto implemented properties:

Name space CA sample
{
Class employee1
{
Public int pemp id
{
Set;
Get;
}
Public string pename
{
Set;
Get;
}
Public string paddress
{
Set;
Get;
}
Public int page
{
Set;
Get;
}
}
Class employee 5
{
Static void main ()
{
Employee 1 obj  = new Employee1 {p emp id = 101, p ename ‘Raju’ p address = ‘’ hyd, page - 23};
C.W.L (“Id is :-”  obj. p emp id);
C.W.L (“Name is :-”  obj. p ename);
C.W.L (“Address is :-”  obj. p Address);
C.W.L (“Age is :-”  obj. page);
}
}
}

For in-depth understanding click on

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.