C requires a lot of boilerplate code even for simple console applications.
We need a namespace a Program class and even a static Main method.
How brilliant would it be if we could create a new file and start writing our code?
C 9 introduces top-level statements.
Top-level statements allow us to write C statements without explicitly creating a namespace a class and a static Main method as an entry point to our program.
Top-level statements make C feel simpler and they help create short example programs to demonstrate language features.
Also it should be more comfortable for beginners to learn all the language features one-by-one.
Top-level statements are essentially a compiler feature.
That means that even if we dont write the boilerplate code ourselves the compiler does the work for us and we end up with the same old structure.
The only limitation I experienced while working with top-level statements is that you can only have top-level statements in a single file.
Top-level statements are a compiler feature introduced in C 9.
Top-level statements allow us to write short and concise C programs.
We can either use them to demonstrate specific language features or make it simpler to get started with C.
00:00 Introduction
00:38 Top-Level Statements
02:40 Generated IL Code
03:15 Using command-line arguments
03:52 Working with Types
04:32 Limitations
04:55 Conclusion
? C.NET Bootcamp: The Fundamentals more Code FRIENDS10 for 10 OFF
? .NET Developer Roadmap
? YouTube Playlists:
The FREE Blazor Crash Course:
C Programming:
? Install and Use C 9 in Visual Studio 2019:
? SharpLab:
SUBSCRIBE FOR MORE VIDEOS
Subscribe: ?
? CONNECT SUPPORT
Twitter:
Blog:
Newsletter:
CREDITS
?
?
Affiliate Link: I earn a small commission at no additional cost
Источник: rutube.ru