什么是“T @ this”意味着在委托声明中? [英] What does "T @this" mean in a delegate declaration?
问题描述
我刚刚使用达斯汀坎贝尔的WeakEvent课程。尽管一味地使用在互联网上发现的代码和贸易;通常是一个糟糕的主意,它比我以前一起入侵的实现要好得多。它似乎迄今为止工作良好,但为了理解代码,我遇到了以下情况:
public class WeakEventHandler< T,E> :IWeakEventHandler< E>
其中T:class
其中E:EventArgs
{
私人委托void OpenEventHandler(T @ this,object sender,E e);
...
我习惯使用<$ c来声明委托类型$ c> object sender 和 EventArgs args
参数,那么 T @this
部分实现?显然它声明了一些 WeakEventHandler
的 T
泛型类型,但我从未见过
之前(和谷歌搜索它是可以理解的无望)。
> @this 表示您可以使用关键字 this
作为变量。
T
只是第一个开放的泛型类型 WeakEventHandler< T,E>
。
I've just added a weak event implementation to a project using Dustin Campbell's WeakEvent class. Although blindly using Code I Found On The Internet™ is generally a bad idea, it's a far better implementation than what I previously hacked together. It seems to work well so far, but in an effort to understand the code I came across the following:
public class WeakEventHandler<T, E> : IWeakEventHandler<E>
where T : class
where E : EventArgs
{
private delegate void OpenEventHandler(T @this, object sender, E e);
...
I'm used to declaring delegates types with just the object sender
and EventArgs args
arguments, so what does the T @this
part achieve? Obviously it is declaring something of WeakEventHandler
's T
generic type but I've never seen @this
before (and googling it is understandably hopeless).
The @this
means you can use the keyword this
as a variable.
The T
is simply the first open generic type of WeakEventHandler<T, E>
.
这篇关于什么是“T @ this”意味着在委托声明中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!