How are strings stored in an object array?

arrays, c#, object, string

Solution

String objects can never be stored directly in an array, or as any other variable. It's always references, even in a simple case such as:

string x = "foo";

Here the value of `x` is a reference, not an object. No expression value is ever an object - it's always either a reference, a value type value, or a pointer.

Problem

``` object[] objs = new object[]{"one","two","three"}; ``` Are the strings stored in the array as references to the string objects ``` [@] - one [@] - two [@] - three ``` or are the string objects stored in the array elements? ``` [one][two][three] ``` Thanks. Edit: Sorry, my fancy diagram failed miserably.

Original source