[Mono-devel-list] methods w/ "param" in interfaces being called from a dll

Herscovici, Avi AHerscovici at Empirix.com
Tue Jul 29 11:10:50 EDT 2003


When you make an interface with a method that has "params object[] foo" in
the parameter list, compile it to a dll then implement it in another place,
the "params" keyword gets ignored!  Here is an example I used to reproduce
this (mind you this used to be fine, and if the interface exists in the same
dll as its implementation or at least the same file, this works fine):


// FIRST FILE (compile after you have compiled the dll with the second file)

using System;

namespace foo {

using bar;

public class A {

static void Main () {

string moo = "moo";
C t = new B();
B s = new B();

t.test(3,moo);
t.test(3);
s.test(3,moo);
s.test(3);
}
}

public class B:C {
public void test (int c,params object[] args) {
Console.WriteLine(c);
}
}
}

// SECOND FILE (compile this to a DLL)

namespace bar {

public interface C {

void test (int c, params object[] args);

}
}

// ERROR!
file1.cs(18) error CS1503: Argument 1: Cannot convert from 'string' to
'object[]'
file1.cs(18) error CS1501: No overload for method `test' takes `2' arguments
file1.cs(18) error CS8006: Could not find any applicable function for this
argument list
file1.cs(19) error CS1501: No overload for method `test' takes `1' arguments
file1.cs(19) error CS8006: Could not find any applicable function for this
argument list



More information about the Mono-devel-list mailing list