- 
                Notifications
    You must be signed in to change notification settings 
- Fork 12
Home
#Welcome to the CSharp7Features wiki!
New langauge Syntax to improve readability for numeric constants.
int binary = 0b1001_1010_1001_0100;
int hex = 0x1c_a0_41_fe;
double real = 1_00.99_9e-1_000;
Declare out variablie inline.
public static void OutVarTest(string @int)
{
  int.TryParse(@int, out int t);
  Console.WriteLine(t);
}
Nesting functions inside other functions to limit their scope and visibility.
- 
Better performance 
- 
Reduced memory pressure public static void BasicExample(){// Lambda FunctionAction lambdaFun = () => Console.WriteLine("I'm Lambda");lambdaFun.Invoke();// Local Functions Basicvoid EmptyLocalFunction(){Console.WriteLine("I'm Local");};EmptyLocalFunction();}
var array = new[] { 1, 2, 3, 4, 5};
ref int GetItem(int[] arrayParam, int index) => ref arrayParam[index];
ref int item = ref GetItem(array, 1);
You can throw exceptions in code constructs that previously were not allowed because throw was a statement.
- 
Null coalescing expressions 
- 
Some lambda expressions 
- 
Expression-bodied public static double Divide(int x, int y){return y != 0 ? x % y : throw new DivideByZeroException();}var a = Divide(10, 0);
C # 6 expression-bodied members expanded
- Constructors
- Finalizers
- Indexers See the code example!
Define custom return types on async methods
- ValueTask
- Designed for the very scenario
A tuple is a data structure that has a specific number and sequence of Elements.
- ValueTuple
- Immutable
Destruct an object to a tuple
Pattern matching (similar to a switch statement that works on the “shape” of the data, for example its type, rather than just the value)
- Constant patterns
- Type patterns
- Var patterns
