A new feature was introduced from C# 7.0 is Expression Bodies. This feature makes your code more readable and can reduce the number of lines of code drastically.

There are 3 types of Expression Bodies are introduced in C# 7.0 and they are 

1) Expression Bodied Accessor

Generally, while declaring a property we use to get as well as set accessor and these are used to return and set the value to the private member. For get accessor, we just return the private member for this we generally have a code block with {} braces and in between, we write a written statement for this it will take 3 to 4 lines of code. Do we really need this? of course NO, in C# 7.0, now we can reduce such implementation in 1 line. Similarly for set Accessor.

2) Expression Bodies Constructor

The same as above, here we can have small constructors (injecting one or two variables to class properties) in 1 or 2 lines instead of 5 to 6 lines of code.

3) Expression Bodies Finalizer 

Hope here no need much explanation as it is understood that we can shortcut even Finalizer or we can say destructors.

Now, we can go into action. Below is the code snippet where we use to do till C# 6.0.

public class ExpressionBodiesOld
{
    private string _myName;

    public string MyName
    {
        get
        {
            return _myName;
        }
        set
        {
            if (value != null)
                _myName = value;
            else
                throw new ApplicationException("Cannot be null");
        }
    }

    public ExpressionBodiesOld(string name)
    {
        MyName = name;
    }

    ~ExpressionBodiesOld()
    {
        Console.WriteLine("Released");
    }
    
}

As observed, it took almost 28 lines. Now below is the simplified code of above by applying Expression Bodies feature which took 18 lines of code. So, we saved 10 lines of code with more readable.

public class ExpressionBodies
{
    private string _myName;

    public string MyName
    {
        // Expression bodied get accessor
        get => _myName;
        // Expression bodied set accessor along with exception expression
        set => _myName = value ?? throw new ApplicationException("Cannot be null");
    }

    // Expression bodied constructor
    public ExpressionBodies(string name) => MyName = name;
    
    // Expression bodied finalizer
    ~ExpressionBodies() => Console.WriteLine("Released");
    
}

Hope, this explanation gives you the concept.

You can see complete code here in GitHub

Happy Coding 🙂