
C#
C#语言为重点的文章
code-jam
~~~
展开
-
弱鸡2,C# 一个List里面都是timer,如果list被clear,timer事件还会执行吗?
原来是不清楚的,不知道list clear之后还会不会执行事件。其实是会的,因为这个timer对象还是在内存中的,只是clear被移除了引用。原猜测是不是垃圾回收之后就会没有。,但实际上执行垃圾回收也没用。不知道.net里面是不是timer不能被回收(因为有事件一直在等待或执行啊,所以不会被回收,因此GC.Collect()也没用?)有大侠知道的话请指点。using S原创 2017-09-05 10:35:16 · 751 阅读 · 0 评论 -
C#创建mysql存储过程
using Dapper;using LabCenterDataAcquisitionSystem.Util;using MySql.Data.MySqlClient;using System;using System.Collections.Generic;namespace LabCenterDataAcquisitionSystem.Mysql{ /// //原创 2017-09-21 02:00:45 · 1043 阅读 · 0 评论 -
一个C#版本的单例模式Xml解析helper
Program.csusing N_31Brands.api.Xml;using System;namespace XmlDemo{ class Program { static void Main(string[] args) { for (int i = 0; i < 10; i++) ...原创 2019-01-07 09:54:06 · 328 阅读 · 0 评论 -
LINQ返回特定类型的结果
C#OptionList = (from a in rows where a.xFitnessLevel == t1 select new HtmlSelectOptionItem {Value = a.xTime, Text = a.xDescription}).ToList()原创 2015-12-23 21:26:55 · 903 阅读 · 0 评论 -
C# 二进制流传输中的字节序问题
C# 大端与小端[C#]大小端字节序(Big Endian和Little Endian)简单易理解,没有什么好说的。转载 2018-06-09 10:31:30 · 828 阅读 · 0 评论 -
C# 将list分组,每组取第一个
//类型class Obj { public int Id { get; set; } public string Name { get; set; } }//list List<Obj> list= new List<Obj>() { new Obj...原创 2014-11-10 17:50:15 · 8471 阅读 · 2 评论 -
C# 中字符串string和字节数组byte[]的转换
简单粗暴,少废话,道理我都懂C# 中字符串string和字节数组byte[]的转换转载 2018-06-07 19:38:23 · 430 阅读 · 0 评论 -
C# 去除字符串里的重复字符
string s = "sdjfasdfjjlasdhfueiuhjfklhasdlkfjhasdjfasdlk"; IEnumerable distinctList = s.Distinct(); return distinctList.Count();C#真是优美。原创 2016-04-25 10:22:50 · 2132 阅读 · 0 评论 -
C# Lookup ArrayList探究
这个讲的不错。关键字: 不变# ToLookup这个讲的也挺好。关键字:一对多。Lookup这个地址是内容相同的。内容同上Array、ArrayList和List三者的区别C#中数组、ArrayList和List三者的区别...转载 2019-05-08 16:59:03 · 256 阅读 · 0 评论 -
C#二进制方式(binary、varbinary、blob、longblog等)读写mysql
C# 二进制方式读写mysql示例 于@2021年8月16日亲测成功(binary、varbinary、blob、longblog等)环境mysql 5.7.NET5 控制台项目特别提一下,使用了Dapper库,因为比较好用表结构如下图:.net项目依赖如下:主要部分代码示例StringBinary.cs, 将字符串转成二进制,存入; 从二进制中取出内容,转为字符串using System;using System.Collections.Generic;using Sys原创 2021-08-16 23:21:13 · 3676 阅读 · 0 评论 -
[C#多线程] 关于Interlocked.Increment 与 Interlocked.Decrement 的理解
这里说的很好了,简单易懂。踏雪无痕的csdn博客原创 2018-06-22 20:19:48 · 3990 阅读 · 0 评论 -
C#使用Aggregate拼接字符串
这应该算是委托的知识。现在有个List list = new List(){aaa,bbb,ccc,ddd},我想拼成如下样式 aaa,bbb,ccc,ddd 这样的一个字符串。该怎么办?var resultStr = list.Aggregate((x, y) => x + "," + y);原创 2015-08-07 10:13:53 · 5814 阅读 · 0 评论 -
C#动态匿名函数用法示例
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication2{ public class Temp { public string name { get; s原创 2017-10-23 17:52:20 · 733 阅读 · 0 评论 -
C# 匿名对象的写法
记录一下。List olist = new List(); olist.Add(new { Name = "Hauk", Age = 22 }); olist.Add(new { Name = "Emily", Age = 22 }); object obj = new { code = 0, selectedChar = resul原创 2016-08-18 12:09:57 · 5412 阅读 · 1 评论 -
C# 雕虫小技
activeLevel = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(activeLevel);转载 2016-01-14 11:26:58 · 639 阅读 · 0 评论 -
C# post
“` static string PostWebRequest(string postUrl, string paramData, Encoding dataEncode) { string ret = string.Empty; try { byte[] byteArray = dataEncode.Get...原创 2018-09-14 11:33:08 · 2011 阅读 · 0 评论 -
弱鸡,C# System.Timers.Timer测试
using System;using System.Threading;using System.Timers;namespace ConsoleApplication1{ class Program { static System.Timers.Timer timer; private static int index = 0;原创 2017-09-04 21:21:07 · 520 阅读 · 0 评论 -
弱鸡3,C# 一个Timer在等待过程中,interval被改变,时间如何处理,
using System;using System.Threading;using System.Timers;using Timer = System.Timers.Timer;namespace ConsoleApplication1{ class Program { private static Timer timer = new Timer();原创 2017-09-08 17:53:24 · 4641 阅读 · 0 评论 -
C#正则表达式从字符串中提取内容
示例:var remark = "对应正数发票代码:033001900211号码:00264713订单号:627959,";string pattern = @"^对应正数发票代码:\d{12}号码:(\d+)订单号:\d{6,7}";string parentFphm = Regex.Match(remark, pattern).Result("$1");非常好用。注意理解正则表达式里面的 $1,$2…等的含义,然后自由发挥。...原创 2021-01-28 19:54:10 · 3836 阅读 · 5 评论 -
C#中获取当前namespace和methodName(static上下文中也可用)
普通方法(非static方法,也非在static class中的方法)获取namespace和methodName就很简单了,反射。略过。现在是在static方法中获取namesapce和methodName的写法: try { } catch (Exception e)原创 2017-10-13 10:28:51 · 1051 阅读 · 0 评论 -
C#转换国内省市区,文本内容来自某area.json文件
没什么好说的,直接上代码。string text = File.ReadAllText(@"C:\area2.json"); JsonSerializer serializer = new JsonSerializer(); StringReader sr = new StringReader(text); var o = serializer.Deserialize(new Jso原创 2017-09-05 11:17:41 · 1926 阅读 · 1 评论 -
C#异步笔记
认真地看了一些C# 5里面 await async的相关代码写法,给自己做一些特别提醒。http://www.cnblogs.com/zhili/archive/2013/05/15/Csharp5asyncandawait.htm终于明白 await 应该是等待完成再执行后面的代码,虽然等待的方法正在执行,但是UI不会卡住而已。async/a原创 2017-02-03 16:27:52 · 595 阅读 · 0 评论