Problem: If we wanted to create a list which contains a collection of strings, we need to do something like this with C# 2.0:
// Creating collection of string
List<string> stringCollection = new List<string>();
stringCollection.Add("The");
stringCollection.Add("Code");
stringCollection.Add("Project");
Solution: Now in C# 3.0, we do in the following way:
IEnumerable<string> stringCollections = new List<string>
{
"The",
"Code",
"Project"
};
This isn't a revolutionary idea, but I think it's very useful, simple and it costs less performance hits than the old one.
I advise to use the latest one.
Thanks :)