Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
In Linq Query why from clause come first as select statment ?
Santosh Kumar Kotnala
13y
9.2k
0
Reply
Submit
It comes first because, in C#, you can't access variables before they are declared.
So, in this query:
var query = from c in "abcde" select c;
we can access 'c' in the select clause because it's already been declared in the from clause and the compiler has inferred it to be of type 'char' because a string is an IEnumerable<char>.
Also, whilst LINQ queries may look a bit like SQL, they're actual based on something called a 'list comprehension' in functional programming languages such as LISP. Consequently, there was no need to change C#'s natural way of doing things to be compatible with SQL.
Vulpes
13y
0
Message