What are the hidden features of C#?

CsharpProgrammingServer Side Programming

The following are the hidden or lesser known useful features of C# −

Lambda Expressions

A lambda expression in C# describes a pattern. It has the token => in an expression context. This is called goes to operator and used when a lambda expression is declared.

Nullables

C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values. The following is the syntax −

<data_type> ? <variable_name> = null;

Null Coalescing Operator

The null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the type of another nullable (or not) value type operand, where an implicit conversion is possible.

AS keyword

The "as" keyword perform conversions between compatible types. It is like a cast operation and it performs only reference conversions, nullable conversions, and boxing conversions. The as operator can't perform other conversions, such as user-defined conversions, which should instead be performed by using cast expressions.

raja
Published on 13-Aug-2018 13:03:04
Advertisements