[Mono-list] Variable number of parameters to an indexer

Susan Mackay susanmackay at optusnet.com.au
Sat Sep 23 04:09:59 EDT 2006

(My apologies if this is a duplicate - it didn't seem to be included the
first time)

I have some code that was originally developed under VS2003 and VS2005 (long
development time!). I'm trying to port it over to the mono environment.

It contains the following indexer in a class:

        public virtual DimensionedValue this[ params int[] Indicies]

Previously this has worked with code such as:

       for( int Index = 0; Index < ExpLength; Index++)
           Expression Exp = ExpList[ Index];
           DimensionedValue DV = (DimensionedValue)Exp;
           VR[Index] = DV;

where VR is a class derived from the class with the above virtual indexer.
(I've split the code up onto several lines to try to figure out the problem
- it normally is a one-line assignment).

The last code line (VR[Index] = DV) generates the error messages

error CS1502: The best overloaded method match for
`ExpressionLib.Value.this[params int[]]' has some invalid arguments
error CS1615: Argument `1' should not be passed with the `' keyword
error CS1501: No overload for method `this' takes `1' arguments

(I've edited out the file name and line/column references from the message)

Can someone please explain the error messages, in particular the second one?

Also, is this something that VS is allowing and mono is not because it is
not really valid C# - or something?



(BTW: what I'm trying to do is be able to express multi-dimensional values
that can have any number of dimensions without this being defined at
compile-time. I could have an indexer with 1 value, one with 2 values, one
with 3 etc but I am trying to make this generic, which I don't think I can
do with specific-parameter indexers).

More information about the Mono-list mailing list