H
Håkan Johansson
Being new to C# I wonder if the index of an array can be some other ordinal
type than int? Coming from Delphi, I can determine the type of the index as
well as the type of the elements, but haven't had any success with C# so
far. The following example yields the compiler error: error CS0118:
'DemoClass.Months' is a 'type' but is used like a 'variable'.
class DemoClass
{
enum Months
{
january, february, march, april, may, june, july, august, september,
october, november, december
}
static void Main()
{
double[] arrIncome = new double[Months];
arrIncome[Months.january] = 1000.0;
//etc., etc..
}
}
Thank you!
Regards Håkan Johansson
type than int? Coming from Delphi, I can determine the type of the index as
well as the type of the elements, but haven't had any success with C# so
far. The following example yields the compiler error: error CS0118:
'DemoClass.Months' is a 'type' but is used like a 'variable'.
class DemoClass
{
enum Months
{
january, february, march, april, may, june, july, august, september,
october, november, december
}
static void Main()
{
double[] arrIncome = new double[Months];
arrIncome[Months.january] = 1000.0;
//etc., etc..
}
}
Thank you!
Regards Håkan Johansson