摘要: //学期末了,用C#演练一下 数据结构的实例 //初学,可能有幼稚的地方,大家不要笑 //要改进的地方 //1.顺序表的第0个元素可以不用它 //这样可以保持索引和数目的一致 //2.增删改插操作可以增加返回值 //用来判断操作的成功 失败 //3.可以定义 error 枚举 //返回值 返回枚举类型 //再建一个类 判断错误类型 //如果有错误 请前辈们多指教 using System; u... 阅读全文
posted @ 2008-06-04 14:10 LMT 阅读(315) 评论(0) 推荐(0)
摘要: 索引器格式 public int this[int index] // Indexer declaration { // get and set accessors } 比如声明了一个SeqList类,里面有一个一维数组myList 怎样通过SeqList[i] 访问到 myList[i] 就可以用索引器实现 class IndexerClass { private... 阅读全文
posted @ 2008-06-04 01:13 LMT 阅读(254) 评论(0) 推荐(0)
摘要: public int GetElm(int index) { if(index>_count-1) { Console.WriteLine("索引超出范围"); //////////////////////////////// } else ... 阅读全文
posted @ 2008-06-03 23:00 LMT 阅读(140) 评论(0) 推荐(0)
摘要: using System; using System.Collections.Generic; public class Example { public static void Main() { List dinosaurs = new List(); Console.WriteLine("\nCapacity: {0}", dinosaurs... 阅读全文
posted @ 2008-06-03 20:08 LMT 阅读(259) 评论(0) 推荐(0)
摘要: // Declare the generic class public class GenericList { void Add(T input) { } } class TestGenericList { private class ExampleClass { } static void Main() { // Declare a list ... 阅读全文
posted @ 2008-06-03 19:43 LMT 阅读(169) 评论(0) 推荐(0)
摘要: class MainClass { public static void Main(string[] args) { int[] hehe=new int[5]{12,6,5,8,9}; Console.WriteLine("array before sorted is as following"); display(hehe); Array.Sort(hehe... 阅读全文
posted @ 2008-06-02 11:23 LMT 阅读(163) 评论(0) 推荐(0)
摘要: 构造函数 如果一个类不包含构造函数,那么编译器将创建一个名为“默认构造函数”的隐含方法,默认构造函数包含一个空白的参数列表。 使用构造函数的注意事项 类的构造函数名要与类名相同 构造函数没有返回类型 一般情况下,构造函数是public类型的 不能显式调用构造函数 析构函数 ~类名(){statement} 析构函数的注意事项 析构函数没有参数 析构函数没有返回值... 阅读全文
posted @ 2008-06-02 10:17 LMT 阅读(169) 评论(0) 推荐(0)