From IT Skills
Jump to: navigation, search


needs .Net version#4


needs .Net version#4.5

Asynchronous methods... Caller Information


needs .Net version#4.6 therefore works on Vista but not XP

$"name: {name}"... (?.)... оператор nameof... До C# 6.0 нельзя было использовать в блоках catch и final оператор await. Сейчас такая возможность появилась.

using static directive


needs .Net version#4.6.2

Tuples unnamed types that contain multiple public fields var alphabetStart = (Alpha: "a", Beta: "b")... unpackaging is called deconstructing the tuple... names of tuple elements can be inferred from the variables used to initialize ... Discards are temporary, write-only variables used in assignments... async Main method... private protected access modifier enables access for derived classes in the same assembly... is pattern expression... switch expression is no longer restricted. Any type may be used... You may add a when clause. The order of case labels is now important

  • C# 7.0 introduces throw expressions.
  • If you don't remember the order of the parameters but know their names, you can send the arguments in any order.

Local functions[edit]

There are two common use cases for local functions: public iterator methods and public async methods. Both types of methods generate code that reports errors later than programmers might expect... to ensure that exceptions arising from argument validation are thrown before the asynchronous


needs .Net version#4.7


needs Visual Studio 2019

You can now add members to interfaces and provide an implementation for those members. Existing implementations inherit the default implementation... C#7.0 introduced syntax for type patterns and constant patterns by using the is expression and the switch statement. These features represented the first tentative steps toward supporting programming paradigms where data and functionality live apart... You can now add the static modifier to #Local functions to ensure that local function doesn't capture (reference) any variables from the enclosing scope.


anonymous types are internal, so if you want to use them across assemblies using dynamic, you'll need to use InternalsVisibleTo.