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.CostumeGroup s 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.CostumeGroup s where cl.CostumeGroupID == groupID select cl);
Why is that?
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.CostumeGroup
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.CostumeGroup
Why is that?
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.
ASKER
Yeah the code convertor i used did that, have changed now.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.