Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between a Struct and a Class

Answer Posted / kirti

The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects,

you will allocate additional memory for referencing each object. In this case, the struct is less expensive.

When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized. It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.

It is an error to initialize an instance field in a struct.

There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.

A struct is a value type, while a class is a reference type.

How big is the datatype int in .NET ?

32 bits.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is asp.net mvc?

1179


What is the need of Action Filters in ASP.Net MVC

1161


What is routeconfig.cs in mvc 4?

1166


mention what are the various methods provided by the dataset object to generate xml?

1064


What is razor code?

1134


explain lazy loading, eager loading, and explicit loading?

1072


What is the significance of nonactionattribute?

1076


What are the possible razor view extensions?

1045


What is conceptual model? : Entity framework

982


what is dot net? what is use dot net? what is benifit of dot net?what is vb dot net? what is ado dot net? what is c#?

2344


Please explain me what the project manager will ask in the interview.The interview is for senior position in .Net (5 years experience )

3022


Explain linq to entities? : Entity framework

1095


How we can register the Area in ASP.Net MVC?

1136


What is entity framework in asp net?

1168


What are the components required to create a route in mvc?

1131