随笔分类 - C#
摘要:最近项目上用到了AD域查询所有的用户,一直不明白C#操作域怎么弄,回来自己研究了一下还是没有弄很明白。 贴出写的代码以便以后使用查询 根据枚举获取查询条件: 枚举获取条件 1 /// <summary> 2 /// 获取查询条件 3 /// </summary> 4 /// <param name="Condition">条件类型枚举</param> 5 /// <returns></returns> 6 public static string GetQueryCondition(QueryEnum
阅读全文
摘要:3.自动实现属性 在.NET2.0中属性是这样写的 //私有字段 private string _name;//共有字段 public string Name { get { return _name; } set { _name = value; } } 可是.NET3.0新加入一种写法 public string Name { get; set; } 3.0中他更简洁了,可实际上编译器编译的时候是有私有字段的
阅读全文
摘要:2.隐式类型 在.NET2.0中我们定义数据类型的时候一般 int i =1;//或int a;a =1; 在.NET3.0加入了隐式类型Var //隐式类型写法: var i = 1;//隐式类型会根据i的赋值来识别是什么类型 //错误写法1 var i = 1; i = "a"; //因为i已经赋值为int 类型1了后面在给i赋值为“a”string类型因为前面是int类型后面是string类型所以他们类型错误 //错误写法2 ...
阅读全文
摘要:c#3.0加入的一些新特性1.泛型集合2.隐式类型3.自动实现属性3.匿名方法4.扩展方法5.Lambda表达式1.泛型集合 在.NET2.0中没有泛型集合定义集合用ArrayList定义很麻烦,现在.NET3.0加入泛型集合。在usingSystem.Collections;命名空间的List<“T”>"T"代表类型可以是简单类型或自己定义的类型。泛型集合写法:View Code List<string> list = new List<string>(); list.Add("abc"); list.Add(&qu
阅读全文
摘要://委托的定义类:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading; namespace CopyWindowsForms{ public delegate void CopyHand(int OpenStr,int SavaStr); public class CopyHandle { public CopyHand CopyHandEvent { get; set; } public v...
阅读全文

浙公网安备 33010602011771号