If you'd prefer to use the older format, you can copy the code from the second example in this article, and continue the tutorial as before. You can imagine that the statements you write are between the open and closing braces in the Main method in the instructions of the tutorial. To follow an existing tutorial, add any new statements to the Program.cs file generated by the template. Local functions can't include any access modifiers (for example, public or protected).īoth top-level statements and implicit using directives simplify the code that makes up your application. They're created as local functions nested inside the generated Main method. You can access args (command-line arguments), use await, and set the exit code. You can add more statements to the program, just like you can add more statements to your Main method in the traditional style. You can look at the code for the new application and imagine that it contains the statements inside the Main method generated by earlier templates, but in the global namespace. The compiler generated class and Main method are declared in the global namespace. The term top-level statements means the compiler generates the class and method elements for your main program. The features that make the new program simpler are top-level statements, global using directives, and implicit using directives. If you want to use the old templates, see Use the old program style later in this article.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |