Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个像这样的简单方法
class Program { public static void show(string name) { Console.WriteLine(name); } }
现在我有一个代表将引用此方法
Action<string> Del = Program.show;
假设我必须向该方法传递一些名称,例如“Jack”。我如何使用代表来做到这一点?我需要它的语法。
谢谢你。
Del.Invoke("Jack");
或者
Del("Jack");
你可以这样称呼它
两者基本上都会做同样的事情。