News for hackers. Stuff that matters.
Re:Is .NET just miles ahead or am I delusional? by ludston on Saturday April 13, 2024 @10:47AM (#40023484)
All the same:

int Foo => 4;

private int Foo { get => 4; }

private int Foo { get { return 4; } }

Re:Is .NET just miles ahead or am I delusional? by thefz on Saturday April 13, 2024 @12:02PM (#40024007)
Do these all compile to the exact same thing?

https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAJboMLoN7LpHoCW...

Yes, so you are right.

I don't get why in IL, the expression bodied member is different, though. Still, makes sense if you have learned C# starting from the most verbose form (3) then (2) was introduced, then (1).

Re:Is .NET just miles ahead or am I delusional? by ludston on Saturday April 13, 2024 @07:21PM (#40027124)
I could probably give 20 different examples of this too. Not all of them would have identical compiler output, but the behaviour would be.

E.g. you could add

private int Foo { get; } = 4;

To the above example given that the behaviour is identical, although the compiled output should be different so I didn't to avoid any nit pickers.