khalidabuhakmeh,
@khalidabuhakmeh@mastodon.social avatar

Top-level statements are a neat feature of #dotnet, but some implicit returns happen when you add class definitions and functions to the end of the file.

With #JetBrainsRider and #ReSharper, you can have the tooling turn an implicit return into an explicit one, so there’s no confusion about where executing code ends and definitions start. #csharp

JetBrains Rider (thanks to ReSharper) adding an explicit return in a top-level statement file.

range_marten,
@range_marten@dotnet.social avatar

@khalidabuhakmeh top level statements are one of those features I always start out using and then after 10 min convert to class Program

eldamir,
@eldamir@hachyderm.io avatar

@khalidabuhakmeh any info on what the argument for top-level statements is? At first glance, it just seems like a boring feature for lazy people that only serves to make the language more complex. “Syntactic sugar”? That’s a bit of a stretch.
It does - of course - allow C# to have a much shorter Hello World sample, so it doesn’t look too verbose when compared to Python 😅

khalidabuhakmeh,
@khalidabuhakmeh@mastodon.social avatar

@eldamir it's great for developer advocates doing demos. 😅

  • All
  • Subscribed
  • Moderated
  • Favorites
  • dotnet
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines