Hey there! So, today I'm going to be teaching you all about multidimensional arrays!!
Multidimensional arrays are essentially the same things as a standard array. I'll let the coding explain
[hide]
[/hide]
Code:
//So, lets say you want something to be written when you change a comboBox entry. Vs having it set up like this
private void comboBox1_SelectedIndex_Changed(Object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 1)
WriteBytes(0x00, new byte[] { 0x11, 0x83, 0x35, 0x45});
if (comboBox1.SelectedIndex == 2)
WriteBytes(0x00, new byte[] { 0x16, 0x63, 0x34, 0x45});
if (comboBox1.SelectedIndex == 3)
WriteBytes(0x00, new byte[] { 0x14, 0x53, 0x34, 0x45});
}
//if you set up arrays as static byte[] you call load them into a multidimensional array like this
byte[]
phase_0 = { 0x11, 0x83, 0x35, 0x45}),
phase_1 = { 0x16, 0x63, 0x34, 0x45}),
phase_2 = { 0x14, 0x53, 0x34, 0x45});
byte[][] Phases =
{
phase_0, phase_1, phase_2
};
//which can be called like this
private void comboBox1_SelectedIndex_Changed(Object sender, EventArgs e)
{
WriteBytes(0x00, Phases[comboBox1.SelectedIndex]);
}
Now, keep in mind it doesn't have to be a byte[], it can be any other variable so long as it supports an array function!