摘要:
1、数组:由一系列相同类型的元素组成。数组也是引用类型,抽象基类为Array。(不像c、c++那样有连续内存区域)数组元素默认值为0,引用元素为null。2、一维数组的声明与初始化int[] array=new int[5];(默认有5个0的数组)int[] array=new int[]{1,2,3,4,5};(元素已经各自赋值)int[] array=new int[5]{1,2,3,4,5};(当有指定长度且要赋值时就要全部赋值)int[] array={1,2,3,4,5};(直接赋值)int[] array;array=new int{1,2,3,4,5};(先定义再赋值)3、多维数
阅读全文
posted @ 2011-03-18 11:12
穆穆
阅读(173)
推荐(0)
编辑
摘要:
从接口的本身看1、接口不能包含字段。2、接口方法不能有具体实现。3、接口不能实例化。从访问权限看1、接口成员一定是公共的。2、类实现接口中的成员必须是公共的、非静态的。从继承上看1、接口可以被多继承,自身也可多继承。2、基类实现接口,子类继承该实现。3、类的属性和索引器可以为接口上定义的属性或索引器定义额外的访问器。(显示接口实现则不可以!)说明:class MyClass : Interface1 { public string name; public string show { get { return name; } set { name=value;} //这里类添加的 } } in
阅读全文
posted @ 2011-03-18 10:18
穆穆
阅读(268)
推荐(0)
编辑
摘要:
显示接口实现如果一个类继承了多个接口,而接口又有同名的方法或属性,这时就要考虑用显示接口实现,避免错误!例: 1 class Program 2 { 3 static void Main(string[] args) 4 { 5 MyClass a = new MyClass(); 6 a.show(); 7 } 8 } 9 10 class MyClass :Interface1,Interface211 {12 public void show()13 {14 Console.Write("实现接口");15 }16 }17 18 interface Interface
阅读全文
posted @ 2011-03-18 10:03
穆穆
阅读(232)
推荐(0)
编辑