I upgraded one of our projects to C # 6.0 when I found a method that literally did nothing:
private void SomeMethod()
{
return;
}
Now I was wondering if it is possible to rewrite it as a method with an expression, since it contains only return.
Try 1:
private void SomeMethod() => return;
Exceptions:
; Expected,
Invalid 'return' token in class member declaration, structure or interface
Invalid expression term 'return'
Try 2:
private void SomeMethod() => ;
An exception:
- Invalid expression term ';'
Is there any way to achieve this (although this method does not make sense)?
source
share