M
Marc Scheuner [MVP ADSI]
Folks,
I was trying to achieve the following thing: I have a "structure" that
basically is a two-dimensional array of numeric values. Both
dimensions are handled by enumeration types in C#:
public enum Level = { low, medium, high };
public enum Foo = { bar, subbar, superbar };
Now my idea was to create a two-dimensional array using those enum's
as the dimensions, as I'm used to do in Delphi - I tried something
like:
public decimal[,] myValues = new decimal[Level, Foo];
but that didn't seem to work at all.... hmm..... so I really need to
fall back to "int"'s for array indexing?? Gosh.....
Okay, so now I tried to create a class which contains this
two-dimensional array for storage, and I'd like to make it available
to the outside world by means of a public property - indexed by both
it's dimensions, of course - again, like I used to be able to in
Delphi.
I tried:
public class MyClass
{
private decimal[,] m_Values = new decimal[3,3];
public decimal SingleValue[int iDim1, int iDim2]
{
get { return m_Values[iDim1, iDim2]; }
set { m_Values[iDim1, iDim2] = value; }
}
}
but that again didn't work.
Am I expecting too much from C#, or am I just missing an important
point somewhere along the lines of converting from Delphi to C# ??
Thanks for any hints, tips, pointers
Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
I was trying to achieve the following thing: I have a "structure" that
basically is a two-dimensional array of numeric values. Both
dimensions are handled by enumeration types in C#:
public enum Level = { low, medium, high };
public enum Foo = { bar, subbar, superbar };
Now my idea was to create a two-dimensional array using those enum's
as the dimensions, as I'm used to do in Delphi - I tried something
like:
public decimal[,] myValues = new decimal[Level, Foo];
but that didn't seem to work at all.... hmm..... so I really need to
fall back to "int"'s for array indexing?? Gosh.....
Okay, so now I tried to create a class which contains this
two-dimensional array for storage, and I'd like to make it available
to the outside world by means of a public property - indexed by both
it's dimensions, of course - again, like I used to be able to in
Delphi.
I tried:
public class MyClass
{
private decimal[,] m_Values = new decimal[3,3];
public decimal SingleValue[int iDim1, int iDim2]
{
get { return m_Values[iDim1, iDim2]; }
set { m_Values[iDim1, iDim2] = value; }
}
}
but that again didn't work.
Am I expecting too much from C#, or am I just missing an important
point somewhere along the lines of converting from Delphi to C# ??
Thanks for any hints, tips, pointers
Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch