freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

xx-20xx年c核心語法(總結(jié)-預(yù)覽頁

2024-12-16 02:28 上一頁面

下一頁面
 

【正文】 am { static void Main(string[] args) { long a = 1000000000000。 class Program { static void Main(string[] args) { long a = 1000000000000。 B b = new B()。 (b is B)。 } } } (Property) (1) 使用屬性訪問私有成員 class A { private string m_name。 = lizhiwei。 } public static int Num { get { return m_num。 ()。 } } } class Program { static void Main(string[] args) { A a = new A()。//訪問索引器 get } } (2) 索引器的重載 下面的程序運(yùn)行結(jié)果: lizhiwei li class A { private Hashtable m_map = new Hashtable()。 } set { m_map[key] = value。 (a[001]+ +a[2])。 public string Name { get { return m_name。 } } public string Sex { get { return m_sex。amp。 =name。 } } } class Program { static void Main(string[] args) { B b = new B()。 } } (4) 注意:索引器不能是靜態(tài) (static)的! (delegate) (1) 委托的使用 (類似指向函數(shù)的指針 ) 下面程序運(yùn)行結(jié)果:李志偉 delegate void PrintDelegate(string s)。//新建委托鏈 s(李 志偉 )。 } public void Print(string s)//與委托的返回值、參數(shù)相同的函數(shù) { (name+s+ )。//新建委托鏈 s += new PrintDelegate()。 s = new PrintDelegate()。 s += delegate(string temp) { (temp)。例如: class Program { private void Hello(string name)//無返回值 { (你好, +name+!)。 Actionstring action = 。 (fun(20))。//和是: 11 //簡寫格式 Actionstring action = param = (param)。//25,調(diào)用委托返回 25 } } (event) (1) 實(shí)現(xiàn)事件委托的原理 下面的程序運(yùn)行的結(jié)果: 事件被觸發(fā), 執(zhí)行事件委托鏈 ! 執(zhí)行觸發(fā)事件執(zhí)行的方法 ! 執(zhí)行觸發(fā)事件執(zhí)行的方法 ! class A { public delegate void Publish()。//執(zhí)行事件委托鏈 } } public void Event()//觸發(fā)事件執(zhí)行的方法 { (執(zhí)行觸發(fā)事件執(zhí)行的方法 !)。//訂閱 (注冊 )事件,本質(zhì)是增加委托鏈 ()。//只讀屬性 public AEventArgs(string name) { = name。 //引發(fā)執(zhí)行事件委托鏈的方法,命名方式 :OnEventName protected virtual void OnEvent(AEventArgs e) { PublishEventHandler handler = Publish。 } //事件處理的方法 public void HandlingEvents(object sender, AEventArgs e) { (+ 處理事件?。?! )。 } } 上面的程序使用了 .NET Framework事件設(shè)計(jì)準(zhǔn)則 ,運(yùn)行結(jié)果: 事件被觸發(fā)!?。? 李志偉 處理事件?。。? (virtual) (1) 使用 new隱藏基類方法 下 面的程序運(yùn)行結(jié)果: class A { public void print() { ()。 ()。 } } class Program { static void Main(string[] args) { B b = new B()。// } } (abstract) (1)抽象類的使用 abstract class A { protected string m_name。 } } class B : A { public override void print()//必須使用 override或 new,否則報(bào)錯(cuò) { ()。 = 李志偉 。 get。} get{ return m_name。 } } (2)接口里不能包含成員變量、構(gòu)造器、析構(gòu)器,接口的抽象方法不能使用修飾符 (如:abstract、 public等 ),因?yàn)槌橄蠓椒ū仨毷?public abstract。 } void ()//顯示接口成員實(shí)現(xiàn),不能使用 public等關(guān)鍵字 ,只能是 private { ()。//使用 IA接口訪問, IA的 print() ((IB)a).print()。//隱藏了 IA的 F() } interface IC : IA { void G()。 ()。//值得注意 , 由于 IB隱藏了 IA的 F(),所以這里 調(diào)用 的是 IB的 F() ((IBC)t).F()。 } } class Program { static void Main(string[] args) { B b = new B()。//排序方法 foreach(int i in array) { (i+ )。 = age。 } return ()。 array[1] = new A(張三 , 19)。 } } } (3)為自定義的類定義排序類 (IComparer接口 ) class A { private string name。 } public string Name { get { return name。 private B() { } public static B GetB() { if (b == null) { b = new B()。amp。 } return ()。 array[2] = new A(李四 , 17)。擴(kuò)展方法是通過額外的靜態(tài)方法擴(kuò)展現(xiàn)有的類型。 } public static String StringJoin(this String str1,String str2)//為 String類增加一個(gè)方法 { (str1+str2)。//測試自定義的擴(kuò)展方法 (000000000000000)。 for (int i = 1。//多次被執(zhí)行 } } static void Main(string[] args) { foreach (string s in GetEnumerator(2,20))//遍歷返回的集合 { (s)。 Thread thread = new Thread(threadStart)。 } public static void Calculate() { DateTime time = 。 } } ThreadStart是一個(gè)委托,這 個(gè)委托 的 定義為 void ThreadStart(),沒有參數(shù)與返回值。 Thread thread = new Thread(tStart)。 } public static void Calculate(object arg) { Random ra = new Random()。 使用專門的線程類: class Program { static void Main(string[] args) { MyThread mt = new MyThread(100)。 //等待線程結(jié)束 while ( != ) { (10)。 get。 } //線程執(zhí)行方法 public void Calculate() { Random ra = new Random()。 } } 使用線程類可以有多個(gè)參數(shù)與多個(gè)返回值,十分靈活! 使用匿名方法: class Program { static void Main(string[] args) { int
點(diǎn)擊復(fù)制文檔內(nèi)容
黨政相關(guān)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1