why no need to select in linq

Posted on 2011-10-28
Last Modified: 2012-05-12

I am in the process of getting to grips with c# having used 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?
Question by:scm0sml
    LVL 21

    Expert Comment

    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.

    Author Comment

    Yeah the code convertor i used did that, have changed now.
    LVL 96

    Accepted Solution

    The "why" might be that there are still two different mindsets for the VB.NET and C# development paths, even though Microsoft merged those two teams into one.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Live - One-on-One C# Help from Top Experts

    Solve your toughest problems, fast.
    C# experts are online now and ready to help you.

    Suggested Solutions

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now