
c#
墨色幽灵
机械男,自学编程中,创建博客只为了做笔记,有空自己敲打一些代码实现某些功能。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c# | 枚举和结构体
枚举类型本质上是人为限定了取值范围的几个整数 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication12 { class Program { ...原创 2020-04-26 22:48:35 · 178 阅读 · 0 评论 -
c# | 泛型
为什么需要泛型:避免成员膨胀或者类型膨胀 举个例,一家商品卖苹果和书,需要两个类,并定义了两种盒子(或者两个盒子),但如果商品多起来呢,是不是要定义更多的商品类,而这些商品类未必用的上,因为客人不可能全把商品买过来吧。 在不用泛型之前,程序如下: 一 using System; using System.Collections.Generic; using System.Linq; using S...原创 2020-04-25 16:48:46 · 152 阅读 · 0 评论 -
c# | 接口,抽象类
设计原则 solid srp ocp lsp isp dip 抽象方法被子类实现 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication10 { class...原创 2020-04-22 10:32:09 · 146 阅读 · 0 评论 -
c# | 类(二)重写与多态
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MyLib; namespace ConsoleApplication9 { class Program { stati...原创 2020-04-17 17:34:58 · 231 阅读 · 0 评论 -
c# | 类(一)
什么是类 是一种数据结构, 是一种数据类型 代表现实生活中的“种类” 类是一种数据结构,它可以包含数据成员(常量和字段)、函数成员(方法、属性、事件、索引器、运算符、实例构造函数)以及嵌套类型。类类型支持继承,继承是一种机制,它使派生类可以对基类进行扩展和专用化。 ——《C#语言规范》 ...原创 2020-04-16 12:30:37 · 315 阅读 · 0 评论 -
c# | 事件(二)
完整声明 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplication5 { class Program ...原创 2020-04-14 17:03:54 · 163 阅读 · 0 评论 -
c# | 事件(一)
事件的功能 = 通知 + 可选的事件参数(即详细信息) 事件模型的五个组成部分 1、事件的拥有着(event source,对象) 2、事件成员(event,成员) 3、事件的响应者(event subscriber,成员) 4、事件处理器(event handler,成员)——本质上是一个回调方法 5、事件订阅——把事件处理器与事件关联在一起,本质上是一种以委托类型为基础的“约定” 注意 事件处...原创 2020-04-12 23:21:27 · 217 阅读 · 0 评论 -
c# | 委托
一、无题 委托(delegate)是函数指针的升级版 直接调用:通过函数名来调用函数,CPU通过函数名直接获得函数所在的地址并开始执行->返回 间接调用:通过函数指针来调用函数,CPU通过读取函数指针储存的值获得函数所在地址并开始执行->返回 using System; using System.Collections.Generic; using System.Linq; using...原创 2020-04-11 10:48:23 · 174 阅读 · 0 评论 -
c# | 传值,引用,数组,具名,可选参数
值参数 声明时不带修饰符的形参是值形参,一个值形参对应一个局部变量,只是它的初始值来自该方法调用所提供的相应实参 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplicati...原创 2020-04-08 23:38:44 · 428 阅读 · 0 评论 -
c# | 字段,属性,索引器
一、实例字段和静态字段的功能 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication10 { class...原创 2020-04-05 09:39:24 · 257 阅读 · 0 评论 -
c# | 迭代,foreach
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication10 { class Program { ...原创 2020-04-04 21:43:16 · 139 阅读 · 0 评论 -
c# | 操作符(三)
一、类型强制转换 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static voi...原创 2020-04-04 09:13:28 · 131 阅读 · 0 评论 -
c# |操作符(二)
一、new操作符 在内存当中创造一个类型的实例,并且调用这个实例的实构造器 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Consol...原创 2020-04-02 16:43:56 · 209 阅读 · 0 评论 -
c# | 操作符(一)
一、无题 先上一个不是很理解的例子,希望以后能够搞清楚 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication7 { class Program {...原创 2020-03-31 22:57:22 · 744 阅读 · 0 评论 -
c# | 方法使用,构造器
一、用逐部求精写个方法 要用动词或动词短语给方法命名 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ConsoleApplication...原创 2020-03-31 21:52:18 · 241 阅读 · 0 评论 -
c# | 变量,类型,对象
一、dynamic c#的dynamic类型相类似于js的var,如下图: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Console...原创 2020-03-30 21:59:31 · 204 阅读 · 0 评论 -
c# | 复习下方法的内容
之前学过python,方法这一块用起来差不多,就贴下程序好了 当然,学到了c#命名方法, myVariable 这样命名用于变量名 MyVariable 这样命名用于方法名 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Task...原创 2020-03-29 20:06:40 · 84 阅读 · 0 评论 -
c# | 类与对象
类与对象一、创建类和实例 学校开了虚拟仪器的课程,要求学习c#,但老师讲解过于粗糙(并不算不好,只是不适合我),于是乎,找了b站的视频来学习c#,我不相信,作为一名机械的学生,学计算机语言就一定比计算机专业的同学差(但我的机械设计基础是真的差)。 那,下面几周的时间就是c#的时间了 开搞开搞! 一、创建类和实例 using System; using System.Collections.Gene...原创 2020-03-29 12:27:02 · 231 阅读 · 0 评论