C # 7.2 is a single-point version, which adds a number of useful features. A key feature of this version is to avoid unnecessary duplication or distribution, resulting in more efficient handling type value.
Use C # 7.2 language versions of selected configuration element to select the language compiler version.
Using the language functions introduced 7.2, when value types can be processed reference semantics. They are intended to minimize the value of the type of replication, without causing memory allocation and use of related reference types, and thus enhance performance. Features include:
- For argument
in
modifiers, designated parameter passed by reference, but not modified by calling the method. Will bein
adding a modifier to the parameter is compatible with the source changes . - Method for the return of
ref readonly
modifier, the method returns a value indicating by reference, but not written to the object. If a value is given to the return value, then add theref readonly
modifier is compatible with the source changes . Willreadonly
add a modifier to an existingref
return statement is incompatible change . It requires the caller to updateref
declare a local variable to containreadonly
modifiers. readonly struct
Statement, indicating structure immutable, and should be used asin
parameters are passed to its member methods. Willreadonly
add a modifier to an existing structure declaration is binary compatible change .ref struct
A statement indicating the type of structure direct access to managed memory, and must always be assigned the stack. Willref
add a modifier to an existingstruct
declaration is incompatible change .ref struct
You can not be a member of the class, nor for possible other locations allocated on the heap.
You can write secure efficient code to learn more about all of these changes.
Method calls now named parameters in front of the position parameter (if these named parameters to correct position). For more information, please refer to named and optional parameters .
C # 7.0 implements support for digital delimiters, but does not allow the first character literal value is _
. Hexadecimal text and binary files can now _
begin with. E.g:
int binaryValue = 0b_0101_0101;
The new complex access modifier: private protected
instructions can be accessed by members of the class or derived class contains the same assembly declared. While protected internal
allowing the centralized procedure by the same class or derived class to access, but private protected
restrict access to the derived class declaration focused on the same program.
For more information, see the language reference access modifier .
ref var r = ref (arr != null ? ref arr[0] : ref otherArr[0]);
Variable r
is arr
or otherArr
the first reference value.
For more information, see the Language Reference conditional operator (? :) .