I have a collection of objects. e.g.
List subscription = new List
{
new Subscription{ Type = \"Trial\", Type = \"Offl
I would suggest using List.Add()
:
subscription.Add(new Subscriptioin(...))
LINQ Union()
overkill by wrapping a single item by a List<>
instance:
subscriptions.Union(new List<Subscription> { new Subscriptioin(...) };
You don't. LINQ is for querying, not adding. You add a new item by writing:
subscription.Add(new Subscription { Type = "Foo", Type2 = "Bar", Period = 1 });
(Note that you can't specify the property Type
twice in the same object initializer.)
This isn't using LINQ at all - it's using object initializers and the simple List<T>.Add
method.