Can the index type of an array be determined?
- From: "Håkan Johansson" <hakannospam@xxxxxxxxxxxxxxx>
- Date: Mon, 15 Jan 2007 12:14:07 +0100
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
.
- Follow-Ups:
- Re: Can the index type of an array be determined?
- From: Adam Clauss
- Re: Can the index type of an array be determined?
- From: Scot T Brennecke
- Re: Can the index type of an array be determined?
- Prev by Date: How random is Random()
- Next by Date: Re: How random is Random()
- Previous by thread: How random is Random()
- Next by thread: Re: Can the index type of an array be determined?
- Index(es):
Relevant Pages
|