Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:19:22+00:00 2026-06-13T04:19:22+00:00

As my title is self explanatory, I know how to rectify it but why

  • 0

As my title is self explanatory, I know how to rectify it but why is it so in the first place?

Scenario

I wrote a VB.Net Code

Dim list As List(Of String) = New List(Of String)

//Code to populate list

Dim wherelinq As IEnumerable(Of String) = From s In list Where s.StartsWith("A")

This works fine and gives no error

but the same logic in C# fails

List<string> list = new List<string>();

//Code to populate list

IEnumerable<string> wherelinq = from s in list where s.StartsWith("A");

This gives error

enter image description here

Why this restriction in C#? Anything specific that I am missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:19:24+00:00Added an answer on June 13, 2026 at 4:19 am

    VB.NET and C# are different languages, so it is natural that the LINQ query syntax is different, too: C# requires select s, while VB.NET does not.

    Microsoft’s documentation requires that a query syntax query in C# must end in select or group:

    A query expression must begin with a from clause and must end with a select or group clause. Between the first from clause and the last select or group clause, it can contain one or more of these optional clauses: where, orderby, join, let and even additional from clauses. You can also use the into keyword to enable the result of a join or group clause to serve as the source for additional query clauses in the same query expression.

    See C# language specification, section 7.16, for details on the syntax.

    var wherelinq = from s in list where s.StartsWith("A") select s;
    

    You do not have to add select if you use the function syntax:

    var wherelinq = list.Where(s => s.StartsWith("A"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know my title is not much self-explanatory but let me try to explain
Maybe the title of the question is not very self-explanatory but I don't know
The title is pretty self-explanatory: does anyone know of a (good) properties file reader
Title is quite self explanatory, but I have some animation being done in a
The title is pretty self explanatory, but basically I need the table row to
The title is fairly self-explanatory, but I'll reiterate: What would be a good variable
Title is self-explanatory. I have a good bit of experience with PHP, but I
Mostly self-explanatory, but I just want the song title and artist sent as a
The title is self explanatory, but I'll give an example anyways. int sum(int a,
The title is self explanatory, here is what I have so far, but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.