摘要:
CollectionClass<ItemClass> col = new CollectionClass<ItemClass>();col.Add(new ItemClass);可空类型System.Nullable<type> 缩写为 type?例如: System.Nullable<int> myInt 相当于 int? myInt??运算符int? opl = null;int result = op1*2 ?? 5若op1为null,则将5赋给result。List<T> myCollection = new List< 阅读全文
posted @ 2011-07-18 17:11
绯色卡卡
阅读(110)
评论(0)
推荐(0)
摘要:
<operand> as <type>之适用于下列情况:<operand>类型是<type>类型<operand>可以隐式转换为<type>类型<operand>可以封箱到<type>类型中 阅读全文
posted @ 2011-07-18 15:26
绯色卡卡
阅读(144)
评论(0)
推荐(0)
摘要:
public class ConvClass1{ public int val; public static implicit operator ConvClass2(ConvClass1 op1) { ConvClass2 returnVal = new ConvClass2(); returnVal.val = op1.val; return returnVal; }}public class ConvClass2{ publicdouble val; public static explicit operator ConvClass1(ConvClass2 op1) { ConvClas 阅读全文
posted @ 2011-07-18 15:21
绯色卡卡
阅读(143)
评论(0)
推荐(0)
摘要:
IComparable接口:在要比较的对象的类中实现,可以比较该对象和另一个对象。实现 public int CompareTo(object obj) {}IComparer接口:在一个单独的类中实现,可以比较任意两个对象。实现 public int Compare(object x,object y) {} 阅读全文
posted @ 2011-07-18 15:11
绯色卡卡
阅读(113)
评论(0)
推荐(0)
摘要:
public class AddClass1{ public int val; public static AddClass1 operator +(AddClass op1,AddClass op2) { AddClass1 returnVal = new AddClass1(); returnVal.val = op1.val+op2.val; return returnVal; }}重写Object.Equals()和Object.GetHashCode()。 阅读全文
posted @ 2011-07-18 11:47
绯色卡卡
阅读(113)
评论(0)
推荐(0)
摘要:
<operand> is <type>检查对象是否是给定的类型,或者是否可以转换为给定的类型。 阅读全文
posted @ 2011-07-18 11:35
绯色卡卡
阅读(122)
评论(0)
推荐(0)
摘要:
MyClass mc1 = new MyClass();object mc2 = mc1;也可以把对象封为接口 阅读全文
posted @ 2011-07-18 11:02
绯色卡卡
阅读(263)
评论(0)
推荐(0)
摘要:
实现ICloneable接口public class MyClass : ICloneable{ public object Clone() { ... return ...; }} 阅读全文
posted @ 2011-07-18 10:50
绯色卡卡
阅读(135)
评论(0)
推荐(0)
摘要:
public partial class MyClass{ ...}可以把一个类定义在多处 阅读全文
posted @ 2011-07-18 09:12
绯色卡卡
阅读(122)
评论(0)
推荐(0)
摘要:
隐藏基接口,使用new关键字interface IMyBaseInterface{ void DoSomething();}interface IMyDerivedInterface : IMyBaseInterface{ new void DoSomething();}在接口中定义的属性可以定义get和set哪一个可以访问interface IMyInterface{ int MyInt { get; set; }} 阅读全文
posted @ 2011-07-18 09:04
绯色卡卡
阅读(106)
评论(0)
推荐(0)