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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 21, 2012, 5:07 AM
Jignesh TrivediPosted May 21, 2012, 4:24 AM
Please Refer..
http://msdn.microsoft.com/en-us/library/ah19swz4.aspx
http://www.codeproject.com/Articles/8612/Structs-in-C
hope this help.
David SmithPosted May 21, 2012, 2:45 AM
SenthilkumarPosted May 21, 2012, 12:04 AM
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.
Jignesh TrivediPosted May 20, 2012, 11:54 PM
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.
VulpesPosted May 20, 2012, 6:07 AM
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.