зеркало из https://github.com/mono/mail-archives.git
88 строки
2.6 KiB
HTML
88 строки
2.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-list] Casting delegates
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:jonpryor%40vt.edu">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
|
|
<LINK REL="Previous" HREF="025756.html">
|
|
<LINK REL="Next" HREF="025757.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-list] Casting delegates
|
|
</H1>
|
|
<B>Jonathan Pryor
|
|
</B>
|
|
<A HREF="mailto:jonpryor%40vt.edu"
|
|
TITLE="[Mono-list] Casting delegates">jonpryor@vt.edu
|
|
</A><BR>
|
|
<I>Wed, 16 Feb 2005 07:00:35 -0500</I>
|
|
<P><UL>
|
|
<LI> Previous message: <A HREF="025756.html">[Mono-list] Casting delegates
|
|
</A></li>
|
|
<LI> Next message: <A HREF="025757.html">[Mono-list] CONGRATULATIONS YOU ARE LUCKY WINNER .
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#25770">[ date ]</a>
|
|
<a href="thread.html#25770">[ thread ]</a>
|
|
<a href="subject.html#25770">[ subject ]</a>
|
|
<a href="author.html#25770">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>On Tue, 2005-02-15 at 21:22 +0100, Kris Luyten wrote:
|
|
><i> It seems mcs can not compile statements of the following structure:
|
|
</I>><i> "((PInputEventHandler)each)(this, e);" where each is of type Delegate,
|
|
</I>><i> and PInputEventHandler is defined as "public delegate void
|
|
</I>><i> PInputEventHandler(object sender, PInputEventArgs e);".
|
|
</I>
|
|
In the immortal words of...someone, "It Works For Me" (TM).
|
|
|
|
In particular, the following code compiles under both Mono 1.1.1 and
|
|
svn-trunk:
|
|
|
|
// delegate casting...
|
|
using System;
|
|
|
|
delegate void PInputEventHandler (object sender, EventArgs e);
|
|
|
|
class Test {
|
|
public static void Main ()
|
|
{
|
|
Test t = new Test ();
|
|
Delegate d = new PInputEventHandler (Handler);
|
|
((PInputEventHandler)d) (t, null);
|
|
}
|
|
|
|
private static void Handler (object sender, EventArgs e)
|
|
{
|
|
}
|
|
}
|
|
|
|
Your code should work.
|
|
|
|
- Jon
|
|
|
|
|
|
|
|
</PRE>
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI> Previous message: <A HREF="025756.html">[Mono-list] Casting delegates
|
|
</A></li>
|
|
<LI> Next message: <A HREF="025757.html">[Mono-list] CONGRATULATIONS YOU ARE LUCKY WINNER .
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#25770">[ date ]</a>
|
|
<a href="thread.html#25770">[ thread ]</a>
|
|
<a href="subject.html#25770">[ subject ]</a>
|
|
<a href="author.html#25770">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
</body></html>
|