zoukankan      html  css  js  c++  java
  • c# 委托初用法

     1   public delegate void Print(string printStr);
     2         public static void DelegateMethod(string printStr)
     3         {
     4             Console.WriteLine(printStr.Reverse().ToArray());
     5         }
     6 
     7         static string ReverseString(string s)
     8         {
     9             return new string(s.Reverse().ToArray());
    10         }
    11         static void Main(string[] args)
    12         {
    13             //旧方法 
    14             Print print = DelegateMethod;
    15             print("a string");
    16 
    17             //新方法 
    18             Func<string, string> rev = ReverseString;
    19             Console.WriteLine(rev("a string"));
    20             //原始方法 
    21             Console.WriteLine(ReverseString("a string"));
    22 
    23             Console.ReadKey(true);
    24         }
  • 相关阅读:
    前端基础知识1
    mysql作业
    mysql了解知识点
    mysql3
    数据库作业2
    循环结构经典题型
    计算1
    猜数字游戏
    css的显示
    定位和position定位
  • 原文地址:https://www.cnblogs.com/LiuFengH/p/10075443.html
Copyright © 2011-2022 走看看