You're right, it's rarely very hard to replicate the features in regular C#. It is what they call syntactic sugar. It's just about convenience. You know about automatic properties? The ones that allow you to write public class User { public int Id { get; set; } }
That's extremely easy to replicate in "regular" C# code. Even so, automatic properties are still awesome ;)
Filtering and sorting are pretty much the core of LINQ. Consider you have a list of users, called, well, users
, and you want to find the ones who have logged in today, and display them in order of most recently logged in. Before LINQ, you'd probably do something like create a new list, that you populate based on the original list, by iterating it, adding what meets the criteria, and then implementing some sort of IComparable
. Now you can just do:
users = users.Where(u => u.LastLoggedIn.Date = DateTime.Today)
.OrderBy(u => u.LastLoggedIn).ToList();
Convenience =)