I need some urgent help on this block of code which is throwing up error every time. I get a an error of:
'System.InvalidCastException' occurred in System.Core.dll
This is the block of code..anyone have any idea the correct way to do this. it is slightly difficult for me to pin point the issue as I did not write the code.
public List<PageWithSidebar> ProductRanges
{
get
{
var ranges = this.GetPropertyValue<List<IPublishedContent>>("productRanges");
//return ranges != null ? ranges.Cast<PageWithSidebar>().ToList() : new List<PageWithSidebar>();
return ranges != null ? ranges.Cast<PageWithSidebar>().ToList() : new List<PageWithSidebar>();
}
}
Urgent Help!! cast issue
Hi,
I need some urgent help on this block of code which is throwing up error every time. I get a an error of:
'System.InvalidCastException' occurred in System.Core.dll
This is the block of code..anyone have any idea the correct way to do this. it is slightly difficult for me to pin point the issue as I did not write the code.
Thanks
Nav
Hi Nav,
You need to work out how a
List<IPublishedContent>
can be cast toPageWithSidebar
.Some things to look for:
Jeavon
I sorted it I had to change the Ienumerable to "list"..The code above had this change just before I tested it lol
Thanks for the reply :-)
Nav
is working on a reply...