C# has evolved over several versions to include many new features such as generics, lambda expressions, extension methods, dynamic binding, and more. C# 6 added features like using statements for static members and auto-property initializers. C# 7 included tuples, pattern matching, and local functions. C# 8 focuses on record types, default interface methods, nullable reference types, null coalescing assignment, recursive patterns, negated-condition if statements, and null-conditional await.
19. C#Record Types
public class Triangle : Shape
{
public int A { get; set; }
public int B { get; set; }
public int C { get; set; }
}
public class Triangle(int A, int B, int C )
: Shape {}
20. C#Default interface methods
interface IPoint
{
(int x, int y) GetPoint() { return (0, 0); }
}
class Point : IPoint
{ }
IPoint point = new Point();
point.GetPoint();
23. C#Negated-condition if statement
if( !(shape is Triangle)) {};
if(shape is not Triangle) {};
if!(shape is Triangle) {};
unless (shape is Triangle) {};