Terms: Value Types vs. Ref Types(Continued)

In .NET, a type is Value or Reference is, in  essence,  about where it’s allocated – native memory space or managed memory space.

In C++, it’s decided by how you declare a variable, while in C# it’s determined by the type itself.

C++:

int i; // native stack

int *i = new int(); // native heap 

int ^i = gcnew int(); // managed heap

C#:

int i = new int();// native stack, initialed to be binary 0

int i; // native stack, not initialed

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: