开发者

explicitly casting generics in C# 4 [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broad开发者_开发知识库ly applicable, visit the help center. Closed 11 years ago.

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜