I’m trying to create a list of a class that has nested class in it. Can I somehow use yield in a function to make it shorter and more readeable?
var links = new List<UserLink>();
links.Add(new UserLink
{
Name = "A",
Url = "B.com",
Something = "C",
Parameters =
{
new Parameter { Name = "X", Value = "Y" },
new Parameter { Name = "Z", ParameterValue = "0" }
}
});
The only thing I can think of is using constructor, then it will be shorter, though less readable:
The last part (passing variable number of Parameter objects) can be achieved by the
paramskeyword: