Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

why no need to select in vb.net linq

Hi,

I am in the process of getting to grips with c# having used vb.net for quite some time.

This linq statement in vb:
Dim n = (From cl In GeneralHelper.CostumeGroups Where cl.CostumeGroupID = groupID)

Doesn't need a select at the end to work just fine...

With c# I get an error unless I add the select cl at the end:
dynamic n = (from cl in GeneralHelper.CostumeGroups where cl.CostumeGroupID == groupID select cl);

Why is that?
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

I don't know why VB.NET doesn't require the select but C# does, but you should not be using "dynamic" in this situation. Either "var" or "IEnumerable<CostumeGroup>" would be more appropriate.
Avatar of scm0sml
scm0sml

ASKER

Yeah the code convertor i used did that, have changed now.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial