zoukankan      html  css  js  c++  java
  • c#之委托所有方法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication3
    {
        public delegate void ceshi(string[] names);
        class Program
        {
            static void Main(string[] args)
            {
                string[] a = { "abCdeg", "ssxAf" };
    
                //第一种
                //ProStrSYH(a);
                //ProStrToLower(a);
                //ProStToUpper(a);
                //ceshi aaax = new ceshi(ProStToUpper);
                //for (int i = 0; i < a.Length; i++) 
                //{
                //    Console.WriteLine(a[i]);
                //}
    
                //第二种
                //ceshi aX = ProStToUpper;
                //aX(a);
    
                //第三种
                //ceshi sayhi = delegate(string[] names)
                //{
                //    for (int i = 0; i < a.Length; i++)
                //    {
                //        Console.WriteLine(a[i].ToUpper());
                //    }
                //};
                //sayhi(a);
                //lamda 表达式写法 =>goes to 滚
                ceshi sa = (string[] names) => { for (int i = 0; i < a.Length; i++) { Console.WriteLine(a[i].ToUpper()); } };
                sa(a);
                Console.ReadKey();
            } 
            public static void ProStToUpper(string[] name)
            {
                for (int i = 0; i < name.Length; i++)
                {
                    name[i] = name[i].ToUpper();
                }
            }
    
    
    
            public static void ProStrToLower(string[] name)
            {
                for (int i = 0; i < name.Length; i++)
                {
                    name[i] = name[i].ToLower();
                }
            }
            public static void ProStrSYH(string[] names)
            {
                for (int i = 0; i < names.Length; i++)
                {
                    names[i] = """ + names[i] + """;
                }
            }
        }
    }
    

      

  • 相关阅读:
    url参数中出现+、空格、=、%、&、#等字符的解决办法
    hybrid app、react-native 区别
    native app、web app、hybrid app、react-native 区别
    hybrid app 知识点
    使用过的bug跟踪系统
    移动端点击延迟的解决方案
    Java中的null
    类加载器 知识点
    hashcode 知识点
    stylus 知识点
  • 原文地址:https://www.cnblogs.com/mengluo/p/5519296.html
Copyright © 2011-2022 走看看