0

I am trying to figure how to expand this lambda function into a regular block of code, but can't seem to get it right.

public static IntPtr GetCurrentProcess() => new IntPtr(-1);

Could someone point me in the right direction? Thanks!

user098213
  • 25
  • 6

2 Answers2

1
public static IntPtr GetCurrentProcess() 
{
  return new IntPtr(-1);
}
Nigel
  • 2,961
  • 1
  • 14
  • 32
0

Per what CodeReaper said in the comments, you can get Visual Studio to toggle between block body and expression body:

enter image description here

Click on the method name to put the caret in it, then open the light bulb menu in the margin. Sometimes the lightbulb is a wrench instead. You can also press Ctrl+. to pop this menu, and it has a lot of useful stuff in different contexts, such as writing string s as a new parameter to your constructor and then doing "Add and init field" to add a class level field and a setter for it in the constructor body; worth looking into all the things it can do

Caius Jard
  • 72,509
  • 5
  • 49
  • 80