Public property List needs to Concat 2 types with inheritance?

If these are generic lists, like so: List listA; List listAa; You should be able to do: public IList Lists { get { return listA. Concat(listB.Cast()).ToList(); } } The call to Enumerable. Cast will allow you to convert the List into an IEnumerable (since Aa is a subclass of A), which will make Concat work.

You can then convert this back into a List by calling ToList(). As for the property setter - I would not recommend making this property contain a property setter. This is going to behave in a VERY non-standard manner.

Instead, it would most likely be a much better idea to make a custom method for handling setting the lists. If you're going to pass in a single list, containing Aa and A classes, you could use something like: public void SetLists(IEnumerable newElements) { this.listA.Clear(); this.listAa.Clear(); foreach(A aElem in newElements) { Aa aaElem = aElem as Aa; if (aaElem! = null) this.listAa.

Add(aaElem); else this.listA. Add(aElem); } } In this case, doing the loop will actually be more efficient than trying to use LINQ for setting these arrays, since you're going to have some odd filtering required.

Also, it will work in . Net 4.0 without a cast because of covariance.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions