Quantcast
Channel: 2,000 Things You Should Know About C# » Reference Types
Browsing latest articles
Browse All 11 View Live

Image may be NSFW.
Clik here to view.

#67 – Default Behavior for Reference Type Equality

For reference types, a default equality check normally checks to see if the references are pointing to the exact same object–rather than checking to see if the objects pointed to are equivalent....

View Article



Image may be NSFW.
Clik here to view.

#186 – Value Types on the Heap

Value types are normally allocated on the stack. They can, however, be allocated on the heap–when they are declared within an object.  When an object is instantiated, memory for the entire object,...

View Article

Image may be NSFW.
Clik here to view.

#218 – Store Value-Typed Objects on the Heap Through Boxing

Value-typed objects are typically stored on the stack, while reference-typed objects are stored on the heap.  You can, however, convert an instance of a value type to a reference type object through a...

View Article

Image may be NSFW.
Clik here to view.

#227 – Instances of Classes Are Created on the Heap

Because they are reference types, instances of classes are stored on the heap.  When you instantiate (or create) an instance of a class, the actual object is created on the heap and you reference the...

View Article

Image may be NSFW.
Clik here to view.

#265 – Passing Reference Types by Value

Recall that by default parameters are passed by value to a method.  A copy of the variable is passed to the method, which means that if the method changes the parameter’s value, the change won’t be...

View Article


Image may be NSFW.
Clik here to view.

#266 – You Can’t Prevent a Method from Changing the Contents of Reference Types

We saw that even when you pass a variable by value to a method, if that variable is a reference to an object, the method can change the contents of the object. C# doesn’t have a built-in language...

View Article

Image may be NSFW.
Clik here to view.

#270 – Passing a Reference Type by Reference

When you pass a reference type by value to a method, you pass in a reference to the object.  The method can change the object, but can’t change the reference. public static void AnnotateMotto(Dog d) {...

View Article

Image may be NSFW.
Clik here to view.

#271 – Passing a Reference Type as an Output Parameter

You can pass a reference-typed variable to a method as an output parameter, using the out keyword.  This indicates that the parameter is an output method.  For a reference type, this means that the...

View Article


Image may be NSFW.
Clik here to view.

#570 – Assignment Compatibility for Reference Types

A reference type is assignment compatible if the value being assigned belongs to a type that is either the same as, or is a derived type of, the type of the storage location being assigned to.  You can...

View Article


Image may be NSFW.
Clik here to view.

#926 – How Memory Is Allocated for Objects on the Managed Heap

When your applications starts up, the Garbage Collector (GC) allocates some virtual memory to use as a managed heap.  It creates a pointer to the next available free space in the managed heap, which...

View Article
Browsing latest articles
Browse All 11 View Live


Latest Images