随笔分类 -  【C#】

【C#】Lazy<T> 类
摘要:官方说明: https://docs.microsoft.com/zh-cn/dotnet/api/system.lazy-1?view=net-5.0 实例:https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.En 阅读全文
posted @ 2021-01-04 20:32 絆τ 阅读(109) 评论(0) 推荐(0)
【C#】反射遍历对象属性名与值
摘要:public string GetProperties<T>(T t) { string tStr = string.Empty; if (t == null) { return tStr; } System.Reflection.PropertyInfo[] properties = t.GetT 阅读全文
posted @ 2019-04-24 10:27 絆τ 阅读(402) 评论(0) 推荐(0)
【C#】时间类型修改
摘要:鉴于前后端分离发展的迅速。前端很多时间控件都会读UTC时间。 安利一个小知识 // // 摘要: // Creates a new System.DateTime object that has the same number of ticks as the // specified System. 阅读全文
posted @ 2018-11-20 11:23 絆τ 阅读(480) 评论(0) 推荐(0)
【C#】多数组间的取重取余
摘要:string[] arrRate = new string[] { "a", "b", "c", "d" };//A string[] arrTemp = new string[] { "c", "d", "e" };//B string[] arrUpd = arrRate.Intersect(a 阅读全文
posted @ 2018-11-18 16:34 絆τ 阅读(411) 评论(0) 推荐(0)
【C#】多态
摘要:public class Animal { public virtual void Eat() { Console.WriteLine("Animal eat"); Console.ReadKey(); } } public class Cat : Animal { public override 阅读全文
posted @ 2018-11-17 14:39 絆τ 阅读(128) 评论(0) 推荐(0)
【C#】 break continue return 的区别
摘要:static void Main(string[] args) { Console.WriteLine("使用break退出循环"); for(int i = 0; i < 5; i++) { if (i == 2) { break; } Console.WriteLine(i); } Consol 阅读全文
posted @ 2018-04-14 16:59 絆τ 阅读(182) 评论(0) 推荐(0)
【C#】Convert.ToInt32、(int)和int.Parse三者的区别
摘要:前者适合将object类类型转换成int类型 (int)适合简单数据类型之间的转换; int.Parse适合将string类类型转换成int类型。 阅读全文
posted @ 2018-04-07 13:26 絆τ 阅读(390) 评论(0) 推荐(0)
【C#】递归
摘要:一、阶乘 public int aa(int a) { if (a == 0) { return 1; } else { return a * aa(a - 1); } } 二、斐波那契数列 private static int Fib(int v) { if (v == 1 || v == 2) 阅读全文
posted @ 2018-03-16 09:24 絆τ 阅读(182) 评论(0) 推荐(0)
【C#】用委托(Delegate)的BeginInvoke和EndInvoke方法操作线程
摘要:让我们首先了解下什么时候用到C#异步调用: .NET Framework 允许您C#异步调用任何方法。定义与您需要调用的方法具有相同签名的委托;公共语言运行库将自动为该委托定义具有适当签名的BeginInvoke 和EndInvoke 方法。 BeginInvoke 方法用于启动C#异步调用。它与您 阅读全文
posted @ 2018-03-06 13:12 絆τ 阅读(2232) 评论(4) 推荐(0)
【C#】多线程+委托+匿名方法+Lambda表达式
摘要:线程 下面是百度写的: 定义英文:Thread每个正在系统上运行的程序都是一个进程。每个进程包含一到多个线程。进程也可能是整个程序或者是部分程序的动态执行。线程是一组指令的集合,或者是程序的特殊段,它可以在程序里独立执行。也可以把它理解为代码运行的上下文。所以线程基本上是轻量级的进程,它负责在单个程 阅读全文
posted @ 2018-03-02 16:09 絆τ 阅读(4550) 评论(0) 推荐(0)