Why can't my delegate be public?

  • Thread starter Thread starter relient
  • Start date Start date
R

relient

Title says it all. Here's code to show what I'm trying to say:

public class ClassA
{
public delegate void MyDelegate( );
}

public class MainClass
{
public static void Main( )
{
ClassA classA = new ClassA( );
classA.MyDelegate variable; // error
}
}

Thanks
 
See the spelling of the type of the delegate
it should be

ClassA.MyDelegate instead of classA.MyDelegate

HTH
Kalpesh
 
relient said:
Oh... so delegates are public static by default?

I think you're slightly confused by what you're declaring. It's not
that you're declaring a variable - you're declaring a nested type. It's
sort of like doing:

public class ClassA
{
public class MyDelegate : Delegate
{
}
}

Now, there's no idea of a type being static or not.
 
Back
Top