随笔分类 -  C#

摘要:Reference: https://www.red-gate.com/products/dotnet-development/ants-memory-profiler/learning-memory-management/memory-management-fundamentals 1. What 阅读全文
posted @ 2021-08-05 10:43 FrancisForeverhappy 阅读(34) 评论(0) 推荐(0)
摘要:Subject 单词含义 observer Type: System.IObserver The observer used to publish messages to the subject. observable Type: System.IObservable The observable 阅读全文
posted @ 2021-05-07 14:57 FrancisForeverhappy 阅读(723) 评论(0) 推荐(0)
摘要:引言 微信中的订阅号,订阅博客和QQ微博中关注好友,这些都属于观察者模式的应用 观察者模式介绍 定义 观察者模式定义了一种一对多的依赖关系,让多个观察者对象可以同时监听某一个主题对象,这个主题对象在发生状态变化时,会通知所有观察者对象,使它们能够自动更新自己,解决的是“当一个对象的改变需要同时改变多 阅读全文
posted @ 2021-05-04 18:50 FrancisForeverhappy 阅读(129) 评论(0) 推荐(0)
摘要:C#8.0 引入了“nullable reference types”和“non-nullable reference types” 引用不应为 null。 当变量不应为 null 时,编译器会强制执行规则,以确保在不首先检查它们是否为 null 的情况下,取消引用(dereference)这些变量 阅读全文
posted @ 2021-04-30 17:24 FrancisForeverhappy 阅读(218) 评论(0) 推荐(0)
摘要:语言集成查询 (LINQ) Example: 造一副纸牌,然后执行一系列洗牌操作,每次都会输出序列。 还可以将更新后的顺序与原始顺序进行比较。 // Program.cs // The Main() method static IEnumerable<string> Suits() { yield 阅读全文
posted @ 2021-04-18 15:30 FrancisForeverhappy 阅读(67) 评论(0) 推荐(0)
摘要:继承 继承仅适用于类和接口。 并非所有基类成员都可供派生类继承。 以下成员无法继承: 静态构造函数:用于初始化类的静态数据。 实例构造函数:在创建类的新实例时调用。 每个类都必须定义自己的构造函数。 终结器:由运行时的垃圾回收器调用,用于销毁类实例。 可访问性 虽然基类的其他所有成员都可供派生类继承 阅读全文
posted @ 2021-04-17 11:55 FrancisForeverhappy 阅读(54) 评论(0) 推荐(0)
摘要:Source code https://github.com/dotnet/samples/tree/main/csharp/getting-started/console-webapiclient private static readonly HttpClient client = new Ht 阅读全文
posted @ 2021-04-16 16:10 FrancisForeverhappy 阅读(193) 评论(0) 推荐(0)
摘要:Example class ReadFromFile { static void Main() { // The files used in this example are created in the topic // How to: Write to a Text File. You can 阅读全文
posted @ 2021-04-16 01:46 FrancisForeverhappy 阅读(691) 评论(0) 推荐(0)
摘要:内插表达式,格式字符串 // Example 1 // 可通过在内插表达式后接冒号(“:”)和格式字符串来指定受表达式结果类型支持的格式字符串 // {<interpolationExpression>:<formatString>} var date = new DateTime(1731, 11 阅读全文
posted @ 2021-04-15 00:41 FrancisForeverhappy 阅读(238) 评论(0) 推荐(0)
摘要:Mock Example: var paymentServiceMock = new Mock<IPaymentService>(); A Mock can be: Instructed, you can tell a mock that if a certain method is called 阅读全文
posted @ 2021-04-12 16:47 FrancisForeverhappy 阅读(101) 评论(0) 推荐(0)
摘要:virtual and abstract 在 virtual 方法,任何派生类都可以选择重新实现。 派生类使用 override 关键字定义新的实现。 通常将其称为“重写基类实现”。 virtual 关键字指定派生类可以重写此行为。 还可以声明 abstract 方法,让派生类必须在其中重写此行为。 阅读全文
posted @ 2021-04-11 00:21 FrancisForeverhappy 阅读(109) 评论(0) 推荐(0)
摘要:Member The following list provides an overview of the kinds of members a class can contain. Constants: Constant values associated with the class Field 阅读全文
posted @ 2021-03-26 17:57 FrancisForeverhappy 阅读(125) 评论(0) 推荐(0)
摘要:类声明 (class declarations) A class declaration starts with a header. The header specifies: 类的特性和修饰符 类的名称 基类(从基类继承时) 接口由该类实现。 类型参数 (Type parameters) 例子:P 阅读全文
posted @ 2021-03-21 01:32 FrancisForeverhappy 阅读(51) 评论(0) 推荐(0)
摘要:语言特点 面向对象,面向组件 类型安全 .NET 生态系统 垃圾回收 可以为 null 的类型 异常处理 语言集成查询 (LINQ) 异步操作 统一类型系统 .NET体系结构 C# 程序在 .NET 上运行,而 .NET 是名为公共语言运行时 (CLR) 的虚执行系统和一组类库。 CLR 是 Mic 阅读全文
posted @ 2021-03-20 00:33 FrancisForeverhappy 阅读(75) 评论(0) 推荐(0)