Method Syntax

noun

say it: “METH-ud SIN-taks” /ˈmɛθəd ˈsɪntæks/

Writing a LINQ query as a chain of methods with lambdas, like .Where(...).Select(...).

What is Method Syntax in C#?

Method Syntax — Writing a LINQ query as a chain of method calls with lambdas, such as .Where(...).OrderBy(...).Select(...). It's the more common style, and some operations, like Count() and First(), exist only as methods.

var cheap = products
    .Where(p => p.UnitPrice < 10m)
    .OrderBy(p => p.ProductName)
    .Select(p => p.ProductName);

In a sentence

  • “In method syntax, the same filter is products.Where(p => p.UnitPrice < 10).”

Level: Journeyman · More C# terms at this level

Updated