Home > Software engineering >  Learning c# with VisualStudio. When open new console app doesnt have main or class args as in tutori
Learning c# with VisualStudio. When open new console app doesnt have main or class args as in tutori

Time:04-14

I am using the latest version of windows Visual Studio and I think C# 10. I'm not even familiar with what these arguments mean, but in every tutorial video I've watched (the most recent being 6 months old), as soon as they open a new console application it includes these arguments. Are they necessary for this type of beginner code? Should I learn and include them anyway?

CodePudding user response:

C# uses top level statements now, so the Main function isn't necessary anymore. You can just write code directly at the top of the file and it will act exactly as though it was inside of the old Main function.

CodePudding user response:

Welcome to SO. The omitted main method is a feature starting in C# 9.0 and is described here Main() and command-line arguments.

  • Related