Can the index type of an array be determined?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Pointer row addresses have unexpected numbers
    ... int main ... OH WAITTT I guess that's why Delphi has multi dimensional array support ... Of course you code style is bullshit anyway because any normal sane delphi ... And how stupid your C is with all that RIDICILOUS DUMB PTR crap! ...
    (comp.lang.c)
  • Re: Why is the reason for this error
    ... You need to assign the click event handler to each button in the array, ... AddHandler But2.Click, AddressOf clickNewButton ... > Public Sub Start ... > System Error &Hc0000005& (Visual Basic internal compiler error) ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Please help me overcome the segmentation fault
    ... I'm temped to say that debugger is undefined, ... given a compiler error and I suspect that your news editor wrapped ... You can always use the name of an array as a pointer to its first element. ...
    (comp.lang.c)
  • Any reported problem with this constructs?
    ... I'm triying to get around "(compiler error): ... my debugging experience is close to zero. ... Have ANY real sense under delphi? ... - Exist a reported problem in use .NET classes and Delphi classes in the ...
    (borland.public.delphi.non-technical)
  • New coder question: problems with parsing string to int
    ... I am pretty new to csharp myself, but have been trying to do a few ... // sanity check sanswer and convert to int; ... // this generates a compiler error when you use it ...
    (microsoft.public.dotnet.languages.csharp)