文章分类 - C#|C#/CLI
摘要:ToString("X2") 为C#中的字符串格式控制符 X为 十六进制 2为 每次都是两位数 比如 0x0A ,若没有2,就只会输出0xA 假设有两个数10和26,正常情况十六进制显示0xA、0x1A,这样看起来不整齐,为了好看,可以指定"X2",这样显示出来就是:0x0A、0x1A。 参考网址:
阅读全文
摘要:你可能会好奇.net本身并不支持函数对象,那么这样的特性又是从何而来呢?答案是编译器,我们一看IL代码便会明白了。 首先我给出c#代码: public class TCloser { public Func<int> T1(){ var n = 10; return () => { return n
阅读全文
摘要:1、byte、int为key 2、dictionnary 使用enum、定义自定义的struct时,实现IEquatable <T>接口
阅读全文
摘要:装箱和拆箱是值类型和引用类型之间相互转换是要执行的操作。 1. 装箱在值类型(栈空间)向引用类型(堆空间)转换时发生 2. 拆箱在引用类型向值类型转换时发生 object objValue = 4; int value = (int)objValue; object objValue = 4; in
阅读全文
摘要:All C# classes, of any type, are treated as if they ultimately derive from System.Object. Interestingly, this includes value types! Object provides a
阅读全文
摘要:在这篇博客中,我们将介绍如下内容: ==运算符与基元类型 ==运算符与引用类型 ==运算符与String类型 ==运算符与值类型 ==运算符与泛型 ==运算符与基元类型 我们分别用两种方式比较两个整数,第一个使用的是Equals(int)方法,每二个使用的是==运算符: 1 class Progra
阅读全文
摘要:不重载 operator ==(int、float、.... object等) public struct Int32: IComparable, IFormattable, IConvertible, IComparable<int>, IEquatable<int> 如果您以前从来没有接触过IL
阅读全文
摘要:资源分类: 托管资源指的是.NET可以自动进行回收的资源,主要是指托管堆上分配的内存资源。托管资源的回收工作是不需要人工干预的,有.NET运行库在合适调用垃圾回收器进行回收。 非托管资源指的是.NET不知道如何回收的资源,最常见的一类非托管资源是包装操作系统资源的对象,例如文件,窗口,网络连接,数据
阅读全文
摘要:在 C# 中,new 关键字可用作运算符、修饰符或约束。 1)new 运算符:用于创建对象和调用构造函数。这种大家都比较熟悉,没什么好说的了。 2)new 修饰符:在用作修饰符时,new 关键字可以显式隐藏从基类继承的成员。 3)new 约束:用于在泛型声明中约束可能用作类型参数的参数的类型。 关于
阅读全文
摘要:(SortFilter)Enum.Parse(typeof(SortFilter), "FirstName"); Enum.GetName(typeof(ArrayListBinding.SortFilter), SortFilter.FirstName);
阅读全文
摘要:string[] empnames = (from e in emplist select e.Enaame).ToArray();
阅读全文
摘要:The problem is boxing. It's an act of turning value type into object, which might, or might not be unnecessary. The way Dictionarycompares keys, is es
阅读全文
摘要:注意: 1,String类对equals方法和==进行了override。 2、Type类的getType方法。一个类返回同一个东西。
阅读全文
摘要:But again how do i map this information with the information(LocalVariables defined in a method)" With SymReader the locals can be found via ISymbolMe
阅读全文
摘要:Mono.Cecil - 0.6 项目地址:Mono.Cecil项目描述:In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify t
阅读全文
摘要:1. Mono 和 CLI 简介 这里先介绍一下Mono项目,Mono是微软 CLI 规范的一种实现,类似的还有 .NET Framwark、Portable.NET(该项目已于2012.12月停止). CLI 是 Common Language Infrastructure(公共语言基础)的缩写,
阅读全文
摘要:I wouldn't recommend what you want to do. Why are you using a List<T> in the first place? If you can tell us precisely what characteristics the data-s
阅读全文
摘要:1、dicationary use [ ] to access.... if get, key was not present .error... if set, work good...
阅读全文
摘要:public void Set(float new_x, float new_y); 说明:设置已经存在向量的 x, y值 Vector2 one = Vector2.zero Vector2 two { get { return one; } set { one.Set(value.x, valu
阅读全文
摘要:c#params应用 params 是C#开发语言中关键字, params主要的用处是在给函数传参数的时候用,就是当函数的参数不固定的时候。 在方法声明中的 params 关键字之后不允许任何其他参数,并且在方法声明中只允许一个 params 关键字。 关于参数数组,需掌握以下几点。 (1)若形参表
阅读全文