I am using this line of code in my project and haven`t seen this syntax.
internal static StringBuilder a(this StringBuilder sb, string b) => sb.Append(b).Ap
This line consists of two main features. The first is an extension method which is the method signature defined to the left of the lambda symbol (=>
) and can be identified as an extension method as it uses the this
keyword before the first parameter. The second is called an expression bodied function which is the part to the right of the lambda symbol.
Extension methods
Expression bodied functions
internal static StringBuilder a(this StringBuilder sb, string b)
This part tells us that a
is an extension method to StringBuilder
. You can read more on extension methods here
=> sb.Append(b).Append("\n")
These are functions with no statement body. Instead, you implement them with an expression following the function declaration. This is new feature in C# 6. and called expression-bodied function members. You can read more about them here
If you mean the lambda arrow =>
, it is a feature of C# 6 (expression-bodied function members). Check https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#expression-bodied-function-members