J
John Salerno
Here's my full code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace PatternMatcher
{
class Program
{
private const string path = @"C:\switches.txt";
static void Main(string[] args)
{
RunPatternMatcher();
}
private static void RunPatternMatcher()
{
InitializeArrays();
}
private static void InitializeArrays()
{
//FileStream stream = new FileStream(path, FileMode.Open,
FileAccess.Read);
//StreamReader readSwitchValues = new StreamReader(stream);
StreamReader readSwitchValues = new StreamReader(path);
string[] allSwitchValues =
readSwitchValues.ReadToEnd().Split('|');
readSwitchValues.Close();
string[][,] panelOne = FillPanel(allSwitchValues, 0);
string[][,] panelTwo = FillPanel(allSwitchValues, 8 * 2 * 10);
string[][,] panelThree = FillPanel(allSwitchValues, 8 * 2 *
10 * 2);
string[][,] panelFour = FillPanel(allSwitchValues, 8 * 2 *
10 * 3);
//string[][][,] allPanels = new string[4][][,];
//allPanels[0] = panelOne;
//allPanels[1] = panelTwo;
//allPanels[2] = panelThree;
//allPanels[3] = panelFour;
}
private static string[][,] FillPanel(string[] switches, int
startIndex)
{
string[][,] panel = new string[8][,];
for (int i = 0; i < 8; i++)
{
panel = new string[2, 10];
for (int x = 0; x < 2; x++)
for (int y = 0; y < 10; y++)
panel[x, y] = switches[startIndex++];
}
return panel;
}
}
}
The thing is, I need access to the panel arrays after the
InitializeArrays() method is done, so I guess I can't declare them
within the method. Should they be declared in the RunPatternMatcher
method? Or in the class itself? Should they be static?
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace PatternMatcher
{
class Program
{
private const string path = @"C:\switches.txt";
static void Main(string[] args)
{
RunPatternMatcher();
}
private static void RunPatternMatcher()
{
InitializeArrays();
}
private static void InitializeArrays()
{
//FileStream stream = new FileStream(path, FileMode.Open,
FileAccess.Read);
//StreamReader readSwitchValues = new StreamReader(stream);
StreamReader readSwitchValues = new StreamReader(path);
string[] allSwitchValues =
readSwitchValues.ReadToEnd().Split('|');
readSwitchValues.Close();
string[][,] panelOne = FillPanel(allSwitchValues, 0);
string[][,] panelTwo = FillPanel(allSwitchValues, 8 * 2 * 10);
string[][,] panelThree = FillPanel(allSwitchValues, 8 * 2 *
10 * 2);
string[][,] panelFour = FillPanel(allSwitchValues, 8 * 2 *
10 * 3);
//string[][][,] allPanels = new string[4][][,];
//allPanels[0] = panelOne;
//allPanels[1] = panelTwo;
//allPanels[2] = panelThree;
//allPanels[3] = panelFour;
}
private static string[][,] FillPanel(string[] switches, int
startIndex)
{
string[][,] panel = new string[8][,];
for (int i = 0; i < 8; i++)
{
panel = new string[2, 10];
for (int x = 0; x < 2; x++)
for (int y = 0; y < 10; y++)
panel[x, y] = switches[startIndex++];
}
return panel;
}
}
}
The thing is, I need access to the panel arrays after the
InitializeArrays() method is done, so I guess I can't declare them
within the method. Should they be declared in the RunPatternMatcher
method? Or in the class itself? Should they be static?