Hello everyone, this is my first thread in this .NET forum.
Since I am studying C#.NET in this semester, I reckon this would be just the right place for my asking questions regarding the C# language and the .NET framework:)
I got some experience of ANSI C where you declare an array in stack, so:
would allocate a continous piece of memory in stack which can contain 10 integers in total.
Now that we are in C#, where the Array is of type System.Array, it is an object rather than a "value type variable", isn't it?
This gives us conveniences such like myArray.Sort(); but brings me the question of the above one:
An Array object is allocated in stack or heap?
So far as I know, "value type" variables such as the int and double are allocated in stack whereas "reference type" variables such as the Class object would be allocated in heap... This gives me quite some confusion as I couldn't tell when you:
this "myArray" is a reference to the Array object in heap or acts just as the same with ANSI C?
Thanks in advance!
Since I am studying C#.NET in this semester, I reckon this would be just the right place for my asking questions regarding the C# language and the .NET framework:)
I got some experience of ANSI C where you declare an array in stack, so:
Code:
int[10] myArray;
Now that we are in C#, where the Array is of type System.Array, it is an object rather than a "value type variable", isn't it?
This gives us conveniences such like myArray.Sort(); but brings me the question of the above one:
An Array object is allocated in stack or heap?
So far as I know, "value type" variables such as the int and double are allocated in stack whereas "reference type" variables such as the Class object would be allocated in heap... This gives me quite some confusion as I couldn't tell when you:
Code:
int[] myArray = new int[10];
Thanks in advance!
Comment