摘要: public class Player { public string Id { get; set; } public string Name { get; set; } public int Age { get; set; } public bool IsPlaying { get; set; } 阅读全文
posted @ 2021-03-03 20:21 鑫茂 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 1. int 转换成 enum public enum Suit { Spades, Hearts, Clubs, Diamonds } Suit spades = (Suit)0; Suit hearts = Enum.Parse(typeof(Suit), "1"); Suit tryClubs 阅读全文
posted @ 2021-03-03 20:19 鑫茂 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 使用一:可用于捕获报错时。 using System.Diagnostics; ... StackTrace st = new StackTrace(true); string stackIndent = ""; for (int i = 0; i < st.FrameCount; i++) { S 阅读全文
posted @ 2021-03-03 20:18 鑫茂 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 在自助和局部变量窗口中固定属性 https://docs.microsoft.com/zh-cn/visualstudio/debugger/autos-and-locals-windows?view=vs-2019 固定数据提示、在数据提示中固定属性 https://docs.microsoft. 阅读全文
posted @ 2021-03-03 20:14 鑫茂 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 1. 委托 sequenceDiagram 方法->>委托: 返回值和入参一样 委托->>方法: 调用委托就是调用绑定的方法 delegate int NumTest(int num); int Add(int num) { return num + 10; } void Test() { NumT 阅读全文
posted @ 2021-03-03 20:12 鑫茂 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 引入 log4net.dll 项目->添加->新建项->应用程序配置文件,命名为 log4net.config,并把属性的复制到输出目录设置为 如果较新则复制,后续客户端需要读取在 debug 下的这个文件; 封装日志类 WriteLog 1. log4net.config <?xml versio 阅读全文
posted @ 2021-03-03 19:58 鑫茂 阅读(219) 评论(0) 推荐(0) 编辑
摘要: public static class LogHelper { private static readonly string _baseDir = AppDomain.CurrentDomain.BaseDirectory + "VILog"; private static DateTime _cu 阅读全文
posted @ 2021-03-03 19:45 鑫茂 阅读(110) 评论(0) 推荐(0) 编辑
摘要: using System.Windows.Forms; ... /// <summary> /// 选择保存文件的名称以及路径 取消返回 空""; /// </summary> /// <param name="fileName"></param> /// <param name="filter"> 阅读全文
posted @ 2021-03-03 19:35 鑫茂 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1. string 1. 格式化填充 string str = "this {0} a {1}"; Console.WriteLine(string.Format(str, "is", "boy")); // this is a boy 2. 将数据合并成字符串 string[] strArr = 阅读全文
posted @ 2021-03-03 19:26 鑫茂 阅读(467) 评论(0) 推荐(0) 编辑
摘要: 这里举例两种方式。 1. Newtonsoft.Json.JsonConvert 需要引用外部的 Newtonsoft.Json.dll /// <summary> /// 将json字符串转换为对象(使用Json.net) /// </summary> /// <param name="respo 阅读全文
posted @ 2021-03-03 19:25 鑫茂 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 1. 程序根目录: (D:\\...\\WpfApp1\\WpfApp1\\bin\\Debug") string exePath = Environment.CurrentDirectory; 2. 获取该进程的命令行 (\"D:\\...\\WpfApp1\\WpfApp1\\bin\\Debu 阅读全文
posted @ 2021-03-03 19:21 鑫茂 阅读(516) 评论(0) 推荐(0) 编辑
摘要: 1. 若需要控制 exe 实例数量 bool ret; mutex = new System.Threading.Mutex(true, exename, out ret); if (!ret) { //"系统已经启动" Environment.Exit(0); } 2. 退出时 public Ap 阅读全文
posted @ 2021-03-03 18:43 鑫茂 阅读(678) 评论(0) 推荐(2) 编辑