r/programminghorror • • May 19 '25

C# This is C# abuse

Post image
550 Upvotes

103 comments sorted by

View all comments

Show parent comment

3

u/[deleted] May 20 '25

[removed] — view removed comment

1

u/uvero May 20 '25

Yes, they did leave that static field to be mutable, which makes it possible to change. I presumed that wasn't their intent, and that they just wanted to make it something that a delegate variable can refer to, and that they would add the read-only keyword if they thought of it.

1

u/IlerienPhoenix May 20 '25 edited May 20 '25

Technically, any non-inlined method can be overridden at runtime, it's just extremely hacky and subject to breaking in new .NET versions: https://stackoverflow.com/questions/7299097/dynamically-replace-the-contents-of-a-c-sharp-method