[Mono-devel-list] inheriting from System.Delegate - how?

Ben Maurer 05mauben at hawken.edu
Fri Feb 27 12:13:52 EST 2004


You are not allowed to inherit from Sys.Dele directly. You must use the delegate construct in C#.

If you need to dynamically construct your delegate type, you must do that by using System.Reflection.Emit, which *is* able to emit delegates directly (that is what mcs does).

The document you cited from msdn is actually a statement of Microsoft's behavior. There is nobody restricting you from writing a compiler without this requirement. However, the fact is, most languages do not do it.

-- Ben

>>> David Jung <jungdl at ornl.gov> 02/27/04 11:42 AM >>>
I'm writing an interpreter for a .NET hosted language that includes a 
kind of
function-pointer like construct that I want to expose as delegates to .NET.

According to MS's documentation for the System.Delegate class:
"However, only the system and compilers can derive explicitly from the 
*Delegate* class or from the MulticastDelegate 
Any idea how exactly?  When I try it I get an error from mcs 0.30:
error CS0644: `bilab.Func' cannot inherit from special class 

Is there some switch/define/attribute or something that will allow me to 
do it?
How does mcs do it? (or doesn't it).

Any help appreciated.  Thanks,

Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com

More information about the Mono-devel-list mailing list