随笔分类 - Csharp
摘要:类的关键词 Class 类一般申明在namespace中,枚举和struct一般也在namespace中申明 类的申明语法(类前面可以加访问修饰符) class 类名 { 特征——成员变量 行为——成员方法 保护特征——成员属性 构造函数和析构函数 索引器 运算符重载 静态成员 } 类申明实例 命名
阅读全文
摘要:代码 using System; using System.Runtime.InteropServices.Marshalling; using System.Security.Cryptography.X509Certificates; namespace 实践 { enum E_SceneTyp
阅读全文
摘要:根据是否结束游戏的逻辑选择对掷骰子的过程用bool构建函数 掷骰子 static bool RollDice (w,h,ref Player p1,ref Player p2,Map map) { InfoClear(h); Console.ForegroundColor=p1.type==E_Pl
阅读全文
摘要:玩家结构体包含了玩家类型,玩家位置,玩家初始化构造函数还有画自己的函数方法 玩家结构体 enum E_PlayerType//玩家类型的枚举 { Player, Robot, } struct Player { public E_PlayerType type; //用地图上的索引代替坐标 publ
阅读全文
摘要:地图结构体包含可格子数组、地图初始化构造函数、画地图的函数方法。 地图结构体 struct Map { public Grid[] grids;//声明一个变量类型为Grid的数组在结构体中不用初始化 public Map(int x,int y,int num) // 创建构造函数,传入下x,y作
阅读全文