C#委托基础5——泛型委托Action

来源:互联网 发布:php判断是不是正整数 编辑:程序博客网 时间:2024/06/04 15:01

对于函数返回值为空的情形,可以使用Action泛型委托

[csharp] view plaincopyprint?
  1. class Program  
  2. {  
  3.         // 对于函数返回值为空的情形,可以使用Action泛型委托  
  4.         void Showstring(string s)  
  5.         {  
  6.             Console.WriteLine("显示的string值为{0}",s);  
  7.         }  
  8.   
  9.         static void Main(string[] args)  
  10.         {  
  11.             Program p = new Program();  
  12.   
  13.             Action<string> showstring = p.Showstring;  
  14.             showstring("xy");  
  15.         }  
  16. }  
0 0