Write Clean Code (edit)



Ternary Operator Example (? :)

return value = 10 ? true : false;

Null Coalescing Operator Example (??)

return artist ?? new Artist() {};

Prefer String interpolation

string temp = $"Name: {name}, Age: {age}";

Use expression bodied Methods

public string GetMessage() => return "Hello World";
public string Name => "Afzaal Ahmad Zeeshan"; 

A few things you should know prior to reading this guide:

  1. Improvements to C# that were made in its 6th version
  2. LINQ in .NET framework
  3. Asynchronous programming and Task object in C#
  4. Unsafe programming in C#, which allows you to go into memory management

Curly braces + Check null

public void Draw(Shape shape)
    if (shape == null)
        throw new ArgumentNullException("shape");