摘要: List自带排序方法 List<int> list = new List<int>(); list.Add(3); list.Add(2); list.Add(6); list.Add(1); //list提供的排序方法,默认升序排列 //ArrayList中也有sort排序方法 list.Sort 阅读全文
posted @ 2025-01-21 19:43 cannedmint 阅读(8) 评论(0) 推荐(0) 编辑
摘要: lambda表达式 可以将lambda表达式理解为匿名函数的简写 //基本语法: //(参数列表) => //{ // 函数体 //}; //无参无返回值 Action a = () => { Console.WriteLine("无参无返回值的lambda表达式"); }; a(); //有参数的 阅读全文
posted @ 2025-01-21 18:18 cannedmint 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 匿名函数的意义 匿名函数就是没有名字的函数 匿名函数主要是配合委托和事件使用 //delegate (参数列表) //{ // 函数逻辑 //}; //当函数中传递委托参数或者委托和事件赋值时使用匿名函数 //无参无返回值 //申明 Action a = delegate () { Console. 阅读全文
posted @ 2025-01-21 17:30 cannedmint 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 事件的本质 事件让委托的使用更具有安全性 事件是一种特殊的变量类型 //申明语法: //访问修饰符 event 委托类型 事件名; //事件的使用: //事件是作为成员变量存在于类中 //委托怎么使用,事件就怎么使用 //事件相对于委托的区别: //事件不能再类外部赋值 //事件不能在类外部调用 / 阅读全文
posted @ 2025-01-21 16:33 cannedmint 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 委托 委托是函数的容器,可以理解为表示函数的变量类型 用来存储和传递函数 委托的本质是一个类,用来定义函数的类型(返回值和参数的类型) 函数必须对应和各自“格式”一致的委托 //关键字:delegate //语法:访问修饰符 delegate 返回值 委托名(参数列表); //可以申明在namesp 阅读全文
posted @ 2025-01-21 15:45 cannedmint 阅读(8) 评论(0) 推荐(0) 编辑
摘要: LinkedList LinkedList 是一个可变类型的泛型双向链表 LinkedList<int> linkedList = new LinkedList<int>(); //往链表尾部加 linkedList.Addlast(1); //往链表头部加 linkedList.AddFirst( 阅读全文
posted @ 2025-01-21 11:47 cannedmint 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 数据结构 数据结构是计算机存储、组织数据的方式 数据结构是指互相之间存在一种或多种特定关系的数据元素的集合 比如自定义的一个类也可以称为一种数据结构,类是一个自己定义的数据组合规则 数据结构简单来说就是人定义的存储数据和表示数据之间关系的规则 常用的数据结构 数组、栈、队列、链表、树、图、堆、散列表 阅读全文
posted @ 2025-01-21 10:04 cannedmint 阅读(16) 评论(0) 推荐(0) 编辑
摘要: Dictionary的本质 基于键的哈希代码组织起来的键值对 键值对类型从hashtable的object变成了可以自己指定的泛型 Dictionary<int,string> dictionary = new Dictionary<int,string>(); //增加 //不能出现相同键 dic 阅读全文
posted @ 2025-01-11 07:23 cannedmint 阅读(25) 评论(0) 推荐(0) 编辑
摘要: List的本质 是一个可变类型的泛型数组 List<int> list = new List<int>(); List<string> list2 = new List<string>(); //增加 list.Add(1); list2.Add("string"); List<string> li 阅读全文
posted @ 2025-01-11 06:59 cannedmint 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 泛型约束的概念 让泛型的类型有一定限制 值类型: where 泛型字母 : struct 引用类型: where 泛型字母 : class 存在无参公共构造函数: where 泛型字母 : new() 某个类本身或者其派生类: where 泛型字母 : 类名 某个接口的派生类型: where 泛型字 阅读全文
posted @ 2025-01-11 06:32 cannedmint 阅读(9) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示