02 2023 档案

摘要:1. 单一职责原则(Single Responsibility Principle)类T负责两个不同的职责:职责P1,职责P2。 using System; using System.Collections.Generic; using System.Linq; using System.Text; 阅读全文
posted @ 2023-02-22 13:50 Tammytan 阅读(25) 评论(0) 推荐(0) 编辑
摘要:一.new 约束 new 约束指定泛型类声明中的类型实参必须有公共的无参数构造函数。 若要使用 new 约束,则该类型不能为 抽象类型。 当泛型类创建类型的新实例时,请将 new 约束应用于类型参数,如下面的示例所示: class ItemFactory<T> where T : new() { p 阅读全文
posted @ 2023-02-20 15:37 Tammytan 阅读(108) 评论(0) 推荐(0) 编辑
摘要:1.声明和类型模式:类型为 T 的声明模式在表达式结果为非 NULL 且满足以下任一条件时与表达式匹配 var numbers = new int[] { 10, 20, 30 }; Console.WriteLine(GetSourceLabel(numbers)); // output: 1 v 阅读全文
posted @ 2023-02-03 15:45 Tammytan 阅读(73) 评论(0) 推荐(0) 编辑
摘要:示例 1:goto 在 switch 语句中的使用 class SwitchTest { static void Main() { Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large"); Console.Write("Please e 阅读全文
posted @ 2023-02-02 14:07 Tammytan 阅读(161) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示