1.What is "Object"
2.(C# only) What is the difference between a class and a struct?Loading
1.What is "Object"
2.(C# only) What is the difference between a class and a struct?Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 20, 2012, 2:07 AM EDT
In .NET, the 'Object' class (with a capital 'O') in the System namespace is also the ultimate parent of all other .NET types. The C# keyword 'object' (with a lower case 'o') is simply an alias for this type.
In C# (or .NET generally) classes define reference types and structs define value types.
What this means is that a variable of a class type always contains a reference (or a pointer) to where an object of that class is stored on the managed heap. If such a variable doesn't currently refer to an object, then it is given the special value 'null' instead.
In contrast, a variable of a struct type always contains the actual value of the struct instance itself. Broadly, local variables and 'by value' parameters of struct types are stored on the stack and all other instances of structs are stored on the heap.
Jignesh TrivediRank #16 · 50.3K reputationPosted May 20, 2012, 7:54 PM EDT
An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection.
hope this help.
SenthilkumarRank #387 · 6.5K reputationPosted May 20, 2012, 8:04 PM EDT
The stack is value type, stored in the stack memory.
Class can base class to others and can inherit. The structure can inherit the interface, but can't be base to any type.
Class can have constructor and destructor, but the struct can have only constructor.
Without new, the struct can create the instance of the class.
David SmithRank #999 · 2K reputationPosted May 20, 2012, 10:45 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted May 21, 2012, 12:24 AM EDT
Please Refer..
http://msdn.microsoft.com/en-us/library/ah19swz4.aspx
http://www.codeproject.com/Articles/8612/Structs-in-C
hope this help.
VulpesRank #55 · 29.2K reputationPosted May 21, 2012, 1:07 AM EDT