什么是"这个"用于?

use*_*711 2 c#

我读了一些c#代码,无法理解函数参数中的"this"关键字?有人可以告诉我它用于什么?谢谢.

public static class ControlExtensions
{
    public static void InvokeIfNeeded(this Control ctl,
        Action doit)
    {
        if (ctl.InvokeRequired)
            ctl.Invoke(doit);
        else
            doit();
    }

    public static void InvokeIfNeeded<T>(this Control ctl,
        Action<T> doit, T args)
    {
        if (ctl.InvokeRequired)
            ctl.Invoke(doit, args);
        else
            doit(args);
    }
} 
Run Code Online (Sandbox Code Playgroud)

Ant*_*lev 18

它用于指定扩展方法操作的类型.也就是说,为类(以及所有派生类)public static void InvokeIfNeeded(this Control ctl, Action doit)"添加"一个InvokeIfNeeded方法Control.但是,只有在将声明它们的类的命名空间显式导入范围时,才能使用此方法.