Maybe I'm overextending the capabilities of the language. I'm working on a program to train myself on keyboards of the musical variety using MIDI. I've created two controls, one representing the keyboard and the other representing the musical treble and bass staffs. Between the form, keyboard and staff I've developed a number of conversion tables, usually one, but sometimes two, per control. Some of my code requires that one control access a table from the other. This quickly became too tangled for the clarity of the code or the dependency of one for the other.
So I thought I'd just accumulate the tables into one class and make it static so I don't need to declare an instance of it. I started getting errors in the code and as I corrected one thing a new problem crept up. I've tried different arrangements, including creating public properties to access array elements. And I'll probably have some Dictionaries eventually.
The most notable error I get is when using either a foreach() or for(;;) loop the error I get is that an instance of the class is required.
Questions: How should I declare the class or variables within it? Or, how should I be accessing the data? Or is a static class not the way to go?
What I have tried:
Note that I've also tried to declare the array without the constructor.
namespace Keyboard_Tutor
{
class MTables {
private static Note[] _notes;
public Note this[int i] {
get => _notes[i];
}
static MTables() {
_notes = new Note[] {
new Note(1, 21, 0),
new Note(2, 22, -1),
new Note(3, 23, 1),
new Note(4, 24, 2),
new Note(5, 25, -1),
new Note(6, 26, 3),
new Note(7, 27, -1),
new Note(8, 28, 4),
new Note(9, 29, 5),
new Note(10, 30, -1),
new Note(11, 31, 6),
new Note(12, 32, -1),