
C#
天空下的读白
记录下日常开发中遇到的问题...
展开
-
任务分发均分
用C# 实现任务分发均分#原创 2023-03-02 20:20:21 · 190 阅读 · 0 评论 -
C# 时间
C# 关于时间日期的常用文档原创 2022-08-31 21:35:59 · 7842 阅读 · 0 评论 -
C# System.Web.HttpContext.Current.Server.MapPath 报错问题
HttpContext.Current 报错问题原创 2022-07-06 21:29:49 · 1800 阅读 · 0 评论 -
C# %253A%252F%252F 咋编码
HttpUtility.UrlEncode(HttpUtility.UrlEncode("://"))二次转码reuslt: %253a%252f%252f原创 2021-09-11 09:02:32 · 3470 阅读 · 0 评论 -
C# 各类型转换
文章目录string转换成long类型string转换成long类型string str="123456";方法一:long a=long.Parse(str);方法二:long b=Convert.ToInt64(str);原创 2021-08-24 22:16:15 · 389 阅读 · 0 评论 -
Unable to cast object of type ‘Newtonsoft.Json.Linq.JArray‘ to type ‘Newtonsoft.Json.Linq.JObject‘.
在使用Newtonsoft.Json转换数组原创 2021-04-13 14:02:44 · 6269 阅读 · 0 评论 -
C# 正则 Groups 用法
用法 string str = "date={LastMonths=3}"; string bracketsPattern = @"{(?<name>\w+)=(?<value>\w+)}"; var bracketsMatch = new Regex(bracketsPattern, RegexOptions.IgnoreCase).Matches(str); foreach (Mat原创 2021-01-23 17:55:27 · 747 阅读 · 0 评论 -
C# List<int> 分组
var list = new List<int> {1, 2, 3, 4 ,5,6,7,8,9,10,11}; int count = 0; var groupList = new List<List<int>>() { }; int groupSize = 2; while (count < list.Count) { groupList.Add(list.Skip(count).Take(groupSize...原创 2021-01-15 13:40:17 · 1227 阅读 · 0 评论 -
C# 数组移除指定元素
方式一:通过差集的方式排除0new List<int> { 0,1,2,3,4,5 }.Except(new List<int> { 0 }).ToList()方式二:先去重,在排除0var list=new List<int> { 0,1,2,3,4,5,0 }.Distinct()list.Remove(0);原创 2020-12-03 14:23:04 · 4723 阅读 · 1 评论 -
C# split(‘,‘) 如何转换list<int>类型
原字符串var textStr="1,2,3,4,5,6,7,8,9";想要把textStr转换成List<int>类型采用泛型的方式进行转换List<int> textList = a.Split(',').Cast<int>().ToList();调试的时候发现,Cast<int>()报错System.InvalidCastException:“指定的转换无效解决方法List<int> textList = a.Spl原创 2020-09-09 11:45:43 · 3383 阅读 · 0 评论 -
C# 如何保存变量
字段初始值无法引用非静态字段、方法或属性C#规定在类内部只能定义属性或者变量,并初始化,不能直接变量引用变量。属性内存和变量内存的分配的时间不一样。 属性是用的时候分配,变量是在类初始化时候分配。在初始化类实例之前就调用了字段因为这时this还没被初始化,所以编译会报错。原创 2019-08-26 18:11:12 · 2246 阅读 · 0 评论