C#委托之泛型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication2
{
class Program
{
public delegate int ceshi<T>(T o1, T o2);
static void Main(string[] args)
{
string[] o = { "abCdeg", "ssxAf" };
string xa= zheng<string>(o, delegate(string o1, string o2)
{
string num1 = (string)o1;
string num2 = (string)o2;
return num1.Length - num2.Length; });
Console.WriteLine(xa);
Console.ReadKey();
} public static T zheng<T>(T[] name, ceshi<T> aaax)
{ T max = name[0];
for (int i = 0; i < name.Length; i++)
{
//max-name[i]<0
if (aaax(max, name[i]) < 0)
{
max = name[i];
}
}
return max;
}
}
}
C#委托之泛型的更多相关文章
- C# 委托 (一)—— 委托、 泛型委托与Lambda表达式
C# 委托 (一)—— 委托. 泛型委托与Lambda表达式 2018年08月19日 20:46:47 wnvalentin 阅读数 2992 版权声明:此文乃博主之原创.鄙人才疏,望大侠斧正.此 ...
- c#委托、泛型委托和匿名方法
题外话:别指望看第一遍书就能记住和掌握什么——请看第二遍.第三遍. 本人女猿一枚,2年工作经验,喜欢钻研,喜欢创新,闲暇之余喜欢写写博客,深知自身能力薄弱,如表达错误.不当之处请园友们多多指出,互相交 ...
- 普通委托到泛型委托到Linq
private delegate bool delTest(int a); private void button1_Click(object sender, EventArgs e) { var a ...
- C# 委托和泛型
委托定义: 委托是一个类,它定义了方法的类型,使得可以将方法当作另一个方法的参数来进行传递,这种将方法动态地赋给参数的做法,可以避免在程序中大量使用If-Else(Switch)语句,同时使得程序具有 ...
- 委托、多播委托、泛型委托Func,Action,Predicate,ExpressionTree
当试图通过一个事件触发多个方法,抽象出泛型行为的时候,或许可以考虑使用委托. 通过委托构造函数或委托变量把方法赋值给委托 private delegate double DiscountDel ...
- c#委托、泛型、反射的使用情况
委托:当你传递的参数不是 变量 时,想把一个方法作为参数传递,此时委托就可以做到这点 泛型:当你传递的参数是一个类时,此时用泛型 反射:都说反射是一种耗时的操作,但是却很有用,所以反射他不是拿来滥用的 ...
- 委托、泛型委托、多播委托、匿名函数、lamda表达式、事件
1.为什么要使用委托 将一个方法作为参数传递给另一个方法 2.委托概念 public delegate int 委托名(int a, int b); 声明一个委托类型,可以用访问修饰符修饰,deleg ...
- 委托delegate 泛型委托action<> 返回值泛型委托Func<> 匿名方法 lambda表达式 的理解
1.使用简单委托 namespace 简单委托 { class Program { //委托方法签名 delegate void MyBookDel(int a); //定义委托 static MyB ...
- 委托,匿名方法,Lambda,泛型委托,表达式树
一.委托:完成一个委托应分三个步骤://step01:首先用delegate定义一个委托;public delegate int CalculatorAdd(int x, int y);//step0 ...
随机推荐
- Leetcode: Remove Elements
Given an array and a value, remove all instances of that value in place and return the new length. T ...
- [原创]spring学习笔记:关于springsource-tool-suite插件的安装
1.首先我们得确定自己使用的eclipes的版本,具体方式:打开eclipes > help > About Eclipes > 点击eclipes的logo > 查看ecli ...
- maven的pom报plugins却是的解决方法(转)
maven的pom报plugins却是的解决方法. 引用 Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom: ...
- demo14
/Users/alamps/AndroidStudioProjects/Demo12SimpleAdapter/Demo12SimpleAdapter/src/main/res/layout/tabl ...
- Listview和Gridview自定义分割线
1,ListView和GridView中的每一个条目都有分割线,属性android:footerDividersEnabled表示是否显示分割线,默认是为true,即可见.可以自定义的设置分割线的颜色 ...
- sql xml 入门
/*sql xml 入门: --by jinjazz --http://blog.csdn.net/jinjazz 1.xml: 能认识元素.属性和值 ...
- js this 闭包
var myObject = { value :, increment:function (inc){ ; } }; myObject .increment(); console.log(myObje ...
- 由linux下的多进程编程引发的关于进程间隔离的思考
源代码放到了三个文件中: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include & ...
- 【crunch bang】 tint2-用来控制桌面的布局
tint2配置: #--------------------------------------------- # TINT2 CONFIG FILE #----------------------- ...
- Server编解码 解决Response.Redirect方法传递汉字丢失或乱码