我读了一些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# ×1