English 中文(简体)
B. 需要帮助
原标题:Need help in Event Handling

我有代表

delegate string Mathop<T,F>(T a,F b); 

我宣布这样的事件。

event Mathop<T,F> someevent;

但是,我在这里正遇到一个错误。 它说,T无法找到。 我想请我的<代码>Mathop代表作为我的活动的执行者开展工作。

我在这里做的是错的。

最佳回答

您需要将活动列入一类参数,例如:

class C<T, F>
{
    event Mathop<T, F> someevent;
}

你可以赞同一个没有界定具体类型的活动——想象你能够这样做——只要有两个参数并返回一个str!

有了上述法典,你现在就应该能够做这样的事情。

new C<Int32, Int32>().someevent += MyMethod

密瑟德签署

String MyMethod(Int32 a, Int32 b);
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签