• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Object initialization ASP.net

What is Object initialization:

Object initializes are used to initialize or store the required data in to data field at a class when we create object 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();
}
}
}
Interested in ASP.net Training? Enroll now for FREE demo on 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 indepth understanding click on

Summary
Review Date
Reviewed Item
Object initialization ASP.net

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Object initialization ASP.net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.