Extend the functionality of top-level statements to static methods. #9209
Replies: 2 comments
-
This will have a side effect to make source code sensitive to filesystem structure, which is disliked in many other discussions. If you need exposable methods, use exposable approach (class). |
Beta Was this translation helpful? Give feedback.
0 replies
-
See: https://github.com/dotnet/csharplang/blob/main/meetings/2020/LDM-2020-09-28.md#top-level-functions |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Allow writing C# static methods directly within a file, similar to Program.cs top-level statements, without requiring an explicit static class declaration. Implicitly assume the namespace as <project>.<folder>.<fileName>,
while still supporting explicit namespace declarations for overrides. Internally, these methods can be considered to belong to an implicit static class named _static_g
I Think This approach is feasible in C# due to its support for multiple classes within a single file, allowing for the grouping of these top-level static methods into a common static class.
Beta Was this translation helpful? Give feedback.
All reactions