how to create an Object in c# with example | Boxing and UnBoxing in c#

For any class we will create an object in c#. For example.

if class name is Car, we will create a object with new keyword. Car objCar=new Car();

class Car
{
//parameters and/or methods
}
Class road
{
Car objCar=new Car();
}

We have object keyword in c#. Using this we can assign other object or we can do boxing and unboxing.

int variable= 5;
object objVariable=  variable ; //  variable  is boxed

int variable2= (int)  objVariable ; //  objVariable is unboxed


Please give your valuable articals on this topic. We will post by the name of you, if you like. Please submit your articles in the comments

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar