explicitly casting generics in C# 4 [closed]
Can anyone help me in casting generic collection in c# 4.
Here is the code snippet.
GridView1.DataSource = dataServiceColl.Select(t => t.product_desc="EdibileItem")
It is throwing up runtime error at the below line,
Gridview1.Databind();
Saying it is a HTTP Exception.
I think it should be a simple type cast.
Thanks, Kris.
Use
t => t.product_desc=="EdibileItem"
HTTP Exception? That has nothing to do with casting.
More importantly, why are you assigning "EdibleItem"
to t.product_desc
here?
Select(t => t.product_desc="EdibileItem")
Did you meant ==
instead of =
? If so, would a Where
be more appropriate than a Select
?
I think it all boils down to: what are you trying to achieve, exactly?
精彩评论