Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all objects that don't inherit from System.ValueType reference type?

Am I correct in believing that any object that doesn't inherit from System.ValueType must therefore by definition be a reference type?

I've been unable to find any conclusive documentation to backup this notion.

like image 330
m.edmondson Avatar asked Dec 13 '11 12:12

m.edmondson


People also ask

Are objects reference types?

Objects are an example of a reference type. In the above example, both variables a and b will point to the same student object in memory. If we change a , we will also change b . This is because a and b are not storing the data but a reference to the location where the data is stored.

Does everything inherit from object C#?

Yes, all struct s inherit from System. ValueType which in turn inherits from System. Object .

Are value types derived from system object?

While value types are stored generally in the stack, reference types are stored in the managed heap. A value type derives from System. ValueType and contains the data inside its own memory allocation. In other words, variables or objects or value types have their own copy of the data.


1 Answers

Check if this helps.

enter image description here

like image 94
AksharRoop Avatar answered Sep 25 '22 23:09

AksharRoop