Search code examples
c#arrayssemantics

What is the difference between new[] and new string[]?


Possible Duplicate:
What is this new[] a shorthand for?

Is there any difference between

var strings = new string[] { "hello", "world" };

and

var strings2 = new[] { "hello", "world" };

Solution

  • In this case, no difference, as new[] will infer the provided values type as string.

    See Implicitly typed arrays.