Function Body Expression in C#

Function body expression is convenient when we make a less complicated function in C#. The body expression can decrease our workload dramatically when we are developing a large project.


Original Function

public float AverageThreeScores(float a, float b, float c)
{
     return (a + b + c) / 3;
}

Function body Expression

The function above is quite simple. It takes three parameters and returns the average value of the three parameters. The following code snippet is a simplified version, which does the same job.

public float AverageThreeScores(float a, float b, float c) => (a + b + c) / 3;

1 Reply to “Function Body Expression in C#”

Leave a Reply

Your email address will not be published. Required fields are marked *