Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown operator in c# [duplicate]

Tags:

c#

Hi I'm not an expert in C# and I found this piece of code and don't really understand what it does.

I never saw the operator => in c# before. Is like a redirect?

public byte[] methodA(byte[] data) => 
  this.methodB(data);
like image 476
Sinjuice Avatar asked Dec 19 '22 18:12

Sinjuice


1 Answers

That's called an expression bodied method. It's new in C# 6.0.

It's equivalent to:

public byte[] methodA(byte[] data) {
  return this.methodB(data);
}
like image 198
Glorin Oakenfoot Avatar answered Jan 02 '23 08:01

Glorin Oakenfoot