.Net Framework, Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML

Ado.netAsp.Net 2.0SQLC-SharpXMLFrameworkIISXMLWebServiceArchitecture
UMLProject ManagementSDLCMethodologiesDesign PatterenOOPWCF.Net RemotingWWF
MVPMVCSilver LightN-HibernateAjaxJ-QuerySEO-MarketingSite MapPhp

As we know depend on memory location datatypes are mainly categorised into two section; reference type and value type
Refference type Value type
String, class int, srtuct, date

Major difference between Class and struct
Class support inheritence Structs doesnot support inheritence
Calss supports any type of constructor
class ETGTeam
{
public ETGTeam()
{

}
public ETGTeam(int TeamId)
{

}
}

Struct doenot support any constructor without any parameter.
struct ETGTeam
{
public ETGTeam() // This is invalid in constructor
{

}
public ETGTeam(int TeamId) // This is invalid constructor
{

}
}

Class is reference type (memory location heap) Struct is value type (memory location stack)
The "new" keyword create a new instance (memory location) of class type object. for struct the "new" keyword work differently, instead of allocation a new memory location that simply calls the default constructor.

if the struct object is not fully initialised , it wont allow to compile the code.  

Advantage and disadvantage of using struct object :
as we know retriving data from stack is very fast, so where the object is being fetched straightly, there using struct is always a good idea. disadvantage is when struct object is assigned to another struct object, the full content of that struct is being copied is duplicated and added to the stack. thus can hit the performance.
Leave your comment.
Name
Email
Comments
Tell Us6632+5 =

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

Privacy Policy ©2009 ETG Consultancy, All Rights Reserved Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML