Ive just seen a piece of code that uses a generic list class to instantiate itself in the following manner:

var foo = new List<string>(){"hello", "goodbye"};

The curly braces after the contructor are especially confusing. It reminds me somewhat of

var bar = new string[]{"hi","bye"};

but in the past i've wouldve always used:

var foo = new List<string>(new []{"hello", "goodbye"});

Has anybody got a link explaining the syntax in the first line of code? I wouldnt even know where to begin with googling it.

Edit
Report