您的位置:首页 > 编程语言 > C#

c#之委托所有方法

2016-05-23 11:27 465 查看
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] + "\"";
}
}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: