上一页 1 2 3 4 5 6 7 ··· 18 下一页
摘要: <system.web> <customErrors mode="On" defaultRedirect="/_tip404.html"> <error statusCode="404" redirect="/_tip404.html"></error> <error statusCode="500 阅读全文
posted @ 2022-03-17 19:46 江境纣州 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1、生成公钥和私钥(XML) using(RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()){ string publicKey=rsa.ToXmlString(false); // 公钥 string privateKey= 阅读全文
posted @ 2022-03-15 16:35 江境纣州 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1、源码 public static TSource Aggregate<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, TSource> func) { if (source == null) throw Erro 阅读全文
posted @ 2022-03-03 10:37 江境纣州 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 相当于ToDictionary只能一对一,ToLookUp可以一对多,所以Dictionary<string,string[]>其实应该用LookUp<string,string> using (var context = new KTStoreModel()) { context.Database 阅读全文
posted @ 2022-03-02 17:17 江境纣州 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1、SPList class SPList<T> : List<T> { public decimal Average(Func<T, decimal> s) { var list = (List<T>)this; decimal price = list.Average(s) * decimal. 阅读全文
posted @ 2022-03-02 16:17 江境纣州 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 1、model 注意点1:List<ProductSet> Products的Products必须继承ICollection<T>; 注意点2:ProductSet.CategoryID属性,要XXXXXID; [Table("ProductSet")] public class ProductSe 阅读全文
posted @ 2022-03-02 14:17 江境纣州 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 1、EF关闭自动检测 Database.SetInitializer<EFDBContext>(null); 2、父类BaseDBContext public class BaseDBContext : DbContext { public BaseDBContext(string strConn 阅读全文
posted @ 2022-02-28 14:02 江境纣州 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 如public IDbSet<User> ID { get; set; } 获取属性ID的类型是IDbSet<>,且泛型参数是User类型,代码如下 public Type[] GetAllRegEntityTypes() { var typeList = new List<Type>(); var 阅读全文
posted @ 2022-02-28 10:26 江境纣州 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 今天看到一段代码,try中有return语句,后面还有一个finally,不知道执行过程是什么样的。于是来试验了一下。 1.try和catch中有return时,finally里面的语句会被执行吗 我们可以来分别看看 (1)执行try中的return时 public class tryDemo { 阅读全文
posted @ 2022-02-24 19:34 江境纣州 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 异步的目标不是为了让程序运行的更快,而是为了让资源物尽其用。如果你同步运行,wait()等,都会阻塞当前线程。当前线程不得不等待其他线程的任务完成后再继续执行,在这期间,当前线程没有任何用处,除了等待。这在客户端固然不算什么,客户端的计算能力足够,顶多是界面卡死一小会儿而已,但是在计算密集的服务器应 阅读全文
posted @ 2022-02-24 18:46 江境纣州 阅读(175) 评论(0) 推荐(0) 编辑
摘要: using StackExchange.Redis; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Configuration; using Syst 阅读全文
posted @ 2022-02-24 18:34 江境纣州 阅读(90) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using StackExchange.Redis; nam 阅读全文
posted @ 2022-02-24 18:33 江境纣州 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 1、ZipCompressionUtil using HRS.Lib.Comm.IO; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip; using System; using System.Col 阅读全文
posted @ 2022-02-24 18:10 江境纣州 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 1、值类型数组比较 int[] dataA = new int[] { 0, 1, 2, 3, 4, 5 }; int[] dataB = new int[] { 0, 1, 2, 4, 3, 5 }; List<int> dataC = new List<int> { 0, 1, 2, 3, 4, 阅读全文
posted @ 2022-02-24 15:58 江境纣州 阅读(52) 评论(0) 推荐(0) 编辑
摘要: var str = "abcDEF"; switch (str) { case string x when x.StartsWith("abc"): Console.WriteLine("abc"); break; case string x when x.StartsWith("efc"): Co 阅读全文
posted @ 2022-02-24 14:54 江境纣州 阅读(32) 评论(0) 推荐(0) 编辑
摘要: class Program { static void Main(string[] args) { for (int i = 0; i < 100; i++) { Thread t = new Thread(Test); t.Start(); } Console.Read(); } static v 阅读全文
posted @ 2022-02-23 17:03 江境纣州 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 异步操作时应注意的要点 使用异步方法返回值应避免使用void 对于预计算或者简单计算的函数建议使用Task.FromResult代替Task.Run 避免使用Task.Run()方法执行长时间堵塞线程的工作 避免使用Task.Result和Task.Wait()来堵塞线程 建议使用await来代替c 阅读全文
posted @ 2022-02-23 15:50 江境纣州 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 泛型作为参数和返回值 public static Func<T, R> Memoize<T, R>(Func<T, R> func) where T: IComparable { Dictionary<T, R> cache = new Dictionary<T, R>(); return arg 阅读全文
posted @ 2022-02-22 17:40 江境纣州 阅读(663) 评论(0) 推荐(0) 编辑
摘要: 1、for循环:当闭包通过lambda表达式捕获可变变量时,lambda捕获变量的引用,而不是捕获该变量的当前值。因此,如果任务在变量的引用值更改后运行,则该值将是内存中最新的值,而不是捕获变量时的值。 for (int i = 0; i < 10; i++) { Task.Factory.Star 阅读全文
posted @ 2022-02-22 13:36 江境纣州 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 垃圾回收触发条件 CLR在检测到第0代超出预算时触发一次; 显式调用 System.GC.Collect 方法; Windows 通过Win32函数检测到内存低时触发; CLR 正在卸载 AppDomain 时(一个AppDomain卸载时,CLR认为其中一切都不是根,执行一次涵盖所有代的GC); 阅读全文
posted @ 2022-02-22 11:15 江境纣州 阅读(236) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 18 下一页