© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
3 replies
Rhythmic

❔ Making properties accessible by both static and non-static methods

I had to make a static duplicate of a property, because I wanted it to be accessible by both non-static and static methods:
readonly string[] NoteNames = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
static readonly string[] NoteNamesStatic = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
readonly string[] NoteNames = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
static readonly string[] NoteNamesStatic = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };

Is there a better way of doing this, or do I always need to define it twice?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Static methods
C#CC# / help
3y ago
❔ Static interface methods
C#CC# / help
3y ago
❔ ✅ Static vs. non-Static (?)
C#CC# / help
3y ago
✅ Two methods: struct and non-struct
C#CC# / help
2y ago