小编use*_*711的帖子

什么是"这个"用于?

我读了一些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)

c#

2
推荐指数
1
解决办法
398
查看次数

标签 统计

c# ×1