3 ms·
Actually, adding LINQ to C# did not introduce any new functionality at all. Everything you can do in LINQ you could already accomplish in C# without LINQ. Yes,
by Invisig0th 8y ago
Actually, adding LINQ to C# did not introduce any new functionality at all. Everything you can do in LINQ you could already accomplish in C# without LINQ. Yes, I suppose someone could say that the older code was uglier, but it already had the same capabilities as LINQ.
That's been the case for the majority of supposed "new features" in C# for at least the past 8 years or so -- LINQ, inline variables, anonymous functions, string literals etc. It's all just syntactic sugar on top of existing features.
- Dylan16807 8y agoThat's the general nature of a turing complete language. The purpose of every feature is making things less ugly.
- Invisig0th 8y agoI'd say it's more the general nature of Microsoft in this particular case. "There should be three different ways to do that" has been the case since Windows 3.1.
- contravariant 8y agoLINQ is surprisingly powerful when you start overloading SelectMany, as that allows you to implement Monads nicely.
- balfirevic 8y agoDo you know what "expression trees" are and how they relate to LINQ?
- aragorn2 8y agoIIRC, LINQ can be translated to C# 3.0 without LINQ, so I guess it is syntactic suger but for C# 3.0. To implement it in C# 2.0 one would need to replace expression trees with “home made” query specification classes. It would be a lot of work, it would not be standardized, and it would not be integrated in the language. So the real new feature in C# 3.0 are the expression trees. LINQ is only one place where expression trees are used.
- goto11 8y agoThere is no way you can implement Linq in C# 2.0. C# 2 does not have lambdas and expression trees, so you cannot write an expression which can either be compiled into regular code or into an expression tree depending on context.