I want to create a lookup table that can be referenced from other classes, so I'm trying to create a list of const structures as follows:
public struct DataRouting1 { public struct tParameters { private readonly bool prvFieldbus; private readonly int prvAddressMax; private readonly string prvTypeLabel; private readonly byte prvXTPtype; private readonly string prvPointLabel; private readonly int prvPointMin; private readonly int prvPointMax; private readonly int prvPointValue; private readonly int prvQuantityMax; public tParameters(bool Fieldbus, int AddressMax, string TypeLabel, byte XTPtype, string PointLabel, int PointMin, int PointMax, int PointValue, int QuantityMax) { this.prvFieldbus = Fieldbus; this.prvAddressMax = AddressMax; this.prvTypeLabel = TypeLabel; this.prvXTPtype = XTPtype; this.prvPointLabel = PointLabel; this.prvPointMin = PointMin; this.prvPointMax = PointMax; this.prvPointValue = PointValue; this.prvQuantityMax = QuantityMax; } public bool Fieldbus { get { return Fieldbus; } } public int AddressMax { get { return AddressMax; } } public string TypeLabel { get { return TypeLabel; } } public byte XTPtype { get { return XTPtype; } } public string PointLabel { get { return PointLabel; } } public int PointMin { get { return PointMin; } } public int PointMax { get { return PointMax; } } public int PointValue { get { return PointValue; } } public int QuantityMax { get { return QuantityMax; } } } public static readonly List<tParameters> Parameter = new List<tParameters> { new tParameters (true, 250, "Fieldbus Digital Input", 0x80, "Number", 1, 65535, 0, 255), new tParameters (true, 250, "Fieldbus Digital Output", 0x81, "Number", 1, 65535, 0, 255), new tParameters (true, 250, "Fieldbus Input Register", 0x82, "Number", 1, 65535, 0, 255), . . . }; }
I use it as follows:
if (DataRouting1.Parameter[Index].Fieldbus == false) . .
This compiles correctly, but when I ran it, the program crashed, saying that it had an overflow of memory. I went through the program and found that when I entered the line above, the application called the line
public bool Fieldbus { get { return Fieldbus; } }
and stayed there endlessly. The steps switch between the '{' after 'get' and 'return Fieldbus' selections, so it seems to be entering an infinite loop.
Any ideas what I'm doing wrong?