I have a class with these properties:
public List<CommitmentItem<ITransaction, ITransactionItem>> CommitmentItems;
public List<CapitalCallCommitmentItem> CapitalCallCommitmentItems;
CapitalCallCommitmentIteminherits CommitmentItem. I want the property to CapitalCallCommitmentItemsreturn everything CommitmentItemswhere the type is CapitalCallCommitmentItem. So I tried this code:
get
{
return CommitmentItems
.Where(c => c.GetType() == typeof(CapitalCallCommitmentItem))
.Select(c => (CapitalCallCommitmentItem)c)
.ToList();
}
However, I get an error message:
Error 1: Cannot convert type 'Models.CommitmentItem' to 'Models.CapitalCallCommitmentItem'
What is the right way to do this?
Shawn source
share