C#结构体(Struct)运用实践出真理
public class Program { public static MyStruct myStruct; public Program() { } public class Student { public int Id { get; set; } public string Name { get; set; } public int Age { ge...
C#实现生产和消费
C#实现生产和消费public abstract class DoubleCache<T> { #region 双缓存机制 //也可使用环形buff机制 private ListAndLockSlim<T> lst1 = new ListAndLockSlim<T>(); priva...
C#检测代码块运行耗时多久
//监控性能需引用 System.Diagnostics //荣达2022.11.24测试代码,检测打印耗时 System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); // 开始监...
C#反射将静态类数据反射到字典并读取不同分支的字典数据
然后根据switch case匹配的字典加载/// <summary> /// 获取警报的端口状态 /// </summary> private Dictionary<uint, Dictionary<string, uint>> dictAlarmPort = new ...
C#高级应用之反射,把实体类数据反射到字典
/// <summary> /// 获取警报的端口状态 ///dictAlarmPort 自定义的字典名 /// </summary> private Dictionary<uint, Dictionary<string, uint>> dictAlarmPort = new D...
C#方法和委托的重载必须一致。传参类型都为int,uint报错
今天工作中遇到问题,出现了System.ArgumentException:“无法绑定到目标方法,因其签名或安全透明度与委托类型的签名或安全透明度不兼容。”这个错误有时是因为重载的方法相关推荐: C#方...
Mysql查询最近登录的5个用户数据
private static UserModel ConvertToUserModel(userRow row) { if (row == null) return null; UserModel data = new UserModel() { ID = row.ID, UserGroupID = row.UserGroupID, UserName = r...
C#数据类型
五大类型:类(Class)如:Windows,Form,Console,Sting结构体(Structures)如:Int32,Int64,Single,Double枚举(Enumerations)如:HorizontalAlignment,Visibility接口(Interface)委...
C#数据存储(List泛型、Arrrylist、Hashtable)
一、(List<T>)List泛型 List泛型集合是C#编程中的经常使用的集合之一,相对数组它可以动态的添加元素而不是声明的时候就必须指定大小。相对于ArrayList集合和Hashtable集合的优势是其...