C#学习笔记

程序结构 程序(program)
命名空间(namespace)
类型(type)
成员(member)
程序集(assembly)
程序 ->类型 -> 成员
类型(示例)-> 类 + 接口
成员(示例)-> 字段 + 方法 + 属性 + 事件
编译C# 程序时打包为“程序集” -> { .exe (应用程序) 或 .dll (实现库)}
类型和变量

类型:值类型 (value type) + 引用类型 (reference type)
值类型: 简单类型 (simple type) + 枚举类型 (enum type) + 结构类型 (structtype) + null的类型 (nullable type)
引用类型:类类型 (class type) +接口类型 (interface type) + 数据类型 (array type) + 委托类型 (delegate type)

public class Point {
public int x, y;
public Point(int x , int y) { this.x = x; this.y = y; }
}
对象
Point p1 = new Point(0, 0)
成员
类的成员:静态成员 (static member) + 实例成员 (instance member)。
静态成员属于类,实例成员属于对象(类的实例)。
类型形参

public class Pair
基类(类似子类)
public class Point <-public class Point 3D : Point
字段
public static readonly Color Red = new Color(255, 0, 0);

方法
静态方法-> 类使用
实例方法 -> 对象使用
方法参数
(方法声明)static void Swap (ref int x, ref int y) { }
(方法使用) Swap (ref i, ref j);
虚方法和抽象方法
【C#学习笔记】浅谈C# 多态的魅力(虚方法,抽象,接口实现)

    推荐阅读