Replies: 2 comments 3 replies
-
Without the static modifier those members are instance members and have different rules as to when they can be accessed during the instances lifetime. Field initializers take place prior to the base constructor being called, and at this time it's not permitted to access members of the class except to initialize fields. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
While this works
Version without
static
modifier does not compile:And this works as well:
Why is compiler's behavior different? I mean, what's the reasoning behind the decision to make it like that?
Beta Was this translation helpful? Give feedback.
All reactions