Say I have a class with 2 properties
class TestClass
{
public int propertyOne {get;set;}
public List<int> propertyTwo {get; private set;}
public TestClass()
{
propertyTwo = new List<int>();
}
}
Using linq, I am trying to create a list of TestClass as follows:
var results = from x in MyOtherClass
select new TestClass()
{
propertyOne = x.propertyFirst,
propertyTwo = x.propertyList
};
propertyTwo = x.propertyList actually throws an error, with the squiggly red underline.
How can I implement the equivalent of the propertyTwo.AddRange(other) in this case?
Cheers