Hi Im stuck on a simple problem
Say I have a class
public Abstract Animal
And I have 2 derived classes
public Cat : Animal
{
public int NumberOfLegs {get;set;}
}
So I passed this to my viewpage
System.Web.Mvc.ViewPage((IEnumerable<Animal>)
In the aspx page
I can’t do this(it won’t even compile). It won’t recognize the NumberOflegs member
foreach (item in Model)
(Cat)item.NumberOfLegs
Any Idea?
Thanks in advance
You need to add a couple of paranthesis to have the cast evaluate before you access the member: