C
C#2y ago
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" }; Is there a better way of doing this, or do I always need to define it twice?
3 Replies
TheBoxyBear
TheBoxyBear2y ago
Just make it static. Instances can still access it within the same class or from outside using the class name
Rhythmic
Rhythmic2y ago
Thanks, that seems to work
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.