本文整理汇总了C#中System.Action代理的典型用法代码示例。如果您正苦于以下问题:C# Action代理的具体用法?C# Action怎么用?C# Action使用的例子?那么恭喜您, 这里精选的代理代码示例或许可以为您提供帮助。
Action代理属于System命名空间,在下文中一共展示了Action代理的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowValue
//引入命名空间
using System;
using System.Windows.Forms;
public delegate void ShowValue();
public class Name
{
private string instanceName;
public Name(string name)
{
this.instanceName = name;
}
public void DisplayToConsole()
{
Console.WriteLine(this.instanceName);
}
public void DisplayToWindow()
{
MessageBox.Show(this.instanceName);
}
}
public class testTestDelegate
{
public static void Main()
{
Name testName = new Name("Koani");
ShowValue showMethod = testName.DisplayToWindow;
showMethod();
}
}
示例2: Name
//引入命名空间
using System;
using System.Windows.Forms;
public class Name
{
private string instanceName;
public Name(string name)
{
this.instanceName = name;
}
public void DisplayToConsole()
{
Console.WriteLine(this.instanceName);
}
public void DisplayToWindow()
{
MessageBox.Show(this.instanceName);
}
}
public class testTestDelegate
{
public static void Main()
{
Name testName = new Name("Koani");
Action showMethod = testName.DisplayToWindow;
showMethod();
}
}
示例3: Name
//引入命名空间
using System;
using System.Windows.Forms;
public class Name
{
private string instanceName;
public Name(string name)
{
this.instanceName = name;
}
public void DisplayToConsole()
{
Console.WriteLine(this.instanceName);
}
public void DisplayToWindow()
{
MessageBox.Show(this.instanceName);
}
}
public class Anonymous
{
public static void Main()
{
Name testName = new Name("Koani");
Action showMethod = delegate() { testName.DisplayToWindow();} ;
showMethod();
}
}
示例4: Name
//引入命名空间
using System;
using System.Windows.Forms;
public class Name
{
private string instanceName;
public Name(string name)
{
this.instanceName = name;
}
public void DisplayToConsole()
{
Console.WriteLine(this.instanceName);
}
public void DisplayToWindow()
{
MessageBox.Show(this.instanceName);
}
}
public class LambdaExpression
{
public static void Main()
{
Name testName = new Name("Koani");
Action showMethod = () => testName.DisplayToWindow();
showMethod();
}
}