[Mono-dev] Array of delegate, possible in an interface definition?

Kornél Pál kornelpal at hotmail.com
Mon Dec 5 16:50:19 EST 2005


Hi,

There are two major problems in you code:

1) Delegates are much like function pointers so they have to have a return
type.

2) Interfaces can only contain instance methods, properties and events. No
constands, fields or static members are allowed.

Try this:
 public class Test
 {
  public delegate void TestDelegate (int a, int b);

  public interface TestInterface
  {
   TestDelegate[] CalculateStuff
   {
    get;
   }
  }
 }

Kornél

----- Original Message -----
From: "Sebastian Nowozin" <nowozin at gmail.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Monday, December 05, 2005 10:32 PM
Subject: [Mono-dev] Array of delegate, possible in an interface definition?


Hello everybody,

I have code like this:

public class Test
{
    public delegate TestDelegate (int a, int b);

    public interface TestInterface {
        TestDelegate[] CalculateStuff;
    }
}

On compilation with latest mono mcs 1.1.10, this gives the following errors:
syntax error, got token `SEMICOLON'
File.cs(311,38): error CS1041: Identifier expected
syntax error, got token `SEMICOLON'
File.cs(315,48): error CS1041: Identifier expected
Compilation failed: 2 error(s), 0 warnings

(The line numbers are different as its from real code ;-).  I am not
sure what is wrong with this use of delegates or whether its a mono
bug.

Anyone knows what is wrong?

Thanks,
Sebastian
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list