随笔分类 - C#基础
indexer
摘要:索引器格式 public int this[int index] // Indexer declaration { // get and set accessors } 比如声明了一个SeqList类,里面有一个一维数组myList 怎样通过SeqList[i] 访问到 myList[i] 就可以用索引器实现 class IndexerClass { private...
阅读全文
关于返回值的一个小问题
摘要:public int GetElm(int index) { if(index>_count-1) { Console.WriteLine("索引超出范围"); //////////////////////////////// } else ...
阅读全文
List 泛型类
摘要:using System; using System.Collections.Generic; public class Example { public static void Main() { List dinosaurs = new List(); Console.WriteLine("\nCapacity: {0}", dinosaurs...
阅读全文
泛型
摘要:// Declare the generic class public class GenericList { void Add(T input) { } } class TestGenericList { private class ExampleClass { } static void Main() { // Declare a list ...
阅读全文
Array 静态的 sort()方法
摘要: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...
阅读全文
C# 构造函数&析构函数
摘要:构造函数 如果一个类不包含构造函数,那么编译器将创建一个名为“默认构造函数”的隐含方法,默认构造函数包含一个空白的参数列表。 使用构造函数的注意事项 类的构造函数名要与类名相同 构造函数没有返回类型 一般情况下,构造函数是public类型的 不能显式调用构造函数 析构函数 ~类名(){statement} 析构函数的注意事项 析构函数没有参数 析构函数没有返回值...
阅读全文
浙公网安备 33010602011771号