C# › LINQ
What is LINQ, and what are the two main syntax styles you can use to write a LINQ query?
BeginnerAnswer
LINQ (Language Integrated Query) lets you write expressive, SQL-like queries directly in C# against collections, databases, XML, and more — you can use QUERY syntax (resembling SQL, with 'from...where...select') or METHOD syntax (chained extension methods like .Where().Select()), which are functionally equivalent and interchangeable.
// Query syntax
var adults1 = from p in people where p.Age >= 18 select p.Name;
// Method syntax (equivalent)
var adults2 = people.Where(p => p.Age >= 18).Select(p => p.Name);Real-world example Filtering and projecting a list of Person objects down to just the names of adults, using either syntax style.