




已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
C#應(yīng)用開發(fā)代碼閱讀題1閱讀下面的程序,并寫出執(zhí)行的結(jié)果。(10分)using System;interface Inter1void F();public class A : Inter1public virtual void F()Console.WriteLine(A.F);public class B : A public override void F()Console.WriteLine(B.F);public class C : B,Inter1new public virtual void F()Console.WriteLine(C.F);public class D : C,Inter1public override void F()Console.WriteLine(D.F);void Inter1.F()Console.WriteLine(D.F with Inter1);public class E : Dpublic override void F()Console.WriteLine(E.F);public class Appstatic void M(A a)Inter1 i=(Inter1)a;i.F();static void Main()A a1=new E();B b1=new E();C c1=new E();D d1=new E();E e1=new E();a1.F();b1.F();c1.F();d1.F();e1.F();A a2=new A();A b2=new B();A c2=new C();A d2=new D();A e2=new E();M(a2);M(b2);M(c2);M(d2);M(e2);2閱讀以下程序,試分別描述程序執(zhí)行至,處時(shí),變量s1,s2,c1,c2,c3在堆棧和托管堆中的情況,并說(shuō)明原因。(10分)using System;public delegate void D1(PointStruct mystruct);public delegate void D2(PointClass myclass);public delegate void D3(ref PointStruct mystruct);public struct PointStructpublic int x;public int y;public PointStruct(int x,int y)this.x=x;this.y=y;public class PointClasspublic int x;public int y;public PointClass(int x,int y)this.x = x;this.y = y;class myclasspublic static void SetClass(PointClass p)if (p.x=0)p.x = 100;if (p.x=100)p.y += 100;public static void SetStruct(PointStruct p)if (p.x=0)p.x = 100;if (p.x=100)p.y += 100;public static void SetStruct(ref PointStruct p)if (p.x=0)p.x = 100;if (p.x=100)p.y += 100;static void Main()PointStruct s1 = new PointStruct(0,0);PointClass c1 = new PointClass(0,0);PointStruct s2=s1;PointClass c2=c1;PointClass c3 = new PointClass(100,100);/-SetClass(c1);SetStruct(s1);SetStruct(ref s2);/-D1 d1 = new D1(SetStruct);D2 d2 = new D2(SetClass);D3 d3 = new D3(SetStruct);d1 += d1;d2 += d2;d3 += d3;d1(s2);d2(c2);d2(c3);d3(ref s1);/-Console.WriteLine(the end);C#應(yīng)用開發(fā)寫出運(yùn)行結(jié)果1. using System;class MyTestpublic void swap(ref int x, ref int y) int temp=x;x=y;y=temp;class test static void Main()int a=6, b=8;MyTest app=new MyTest();app.swap(ref a,ref b);Console.WriteLine(“a=0 b=1”, a,b); 2using System;class Test static void Main() for(int i=0;i10;i+) Console.Write(i+ “ ” ); if (i%2!=0)Console.WriteLine(); 1using System;class Test public void F(string s) for (int i=0;i0)return a-;else return 0;class Test static void Main( ) Demo x=new Demo(9 );int k=x.M( );while (k0) Console.Write(“0t ”, k*k); j=x.M( ); 1using System;class StringDe public void f(string s) for (int j=0;js.Length;j+=2) Console.Write(sj);return; public static void Main( ) string str1=“ABCDEFGH” ;StringDe ob=new StringDe( ); ob.f(str1); 3using System; class CounterDown int val; public CounterDown(int n) val=n;public int count( ) if (val0) Console.Write(i*3+ “ ” ); i=cd1.count( ); 1 using System;class Demo2 static void Main( ) int k=1, m; while(k=10) m=k*k;Console.Write(0t , m); k+; 2using System;class ARRAY public static void Main( ) int oddsum=0; int evensum=0; int arr=1,5,2,3,6,7,12,15;foreach (int k in arr) if (k%2= =0)evensum+=k; else oddsum+=k; Console.WriteLine(“evensum=0”,evensum);Console.WriteLine(“oddsum=0”,oddsum); static void Main( ) ARRAY a=new ARRAY();a.Fun(); 1using System; class exception static void Main() for(int i=0;i0) return x-; else return 0; class Test static void Main( ) A a=new A(9 ); int j=a.F( ); while (j0) Console.Write(“0t ”, j*j );j=a.F( ); 1using System; class Test static void Main( ) int i,j,k; for(i=1;i=4;i+) for(j=1;j=4-i;j+)Console.Write( );for(k=1;k=2*i-1;k+)Console.Write(*);Console.WriteLine(); 2using System;class CounterDown int val;public CounterDown(int n) val=n; public int count( ) if (val0) Console.Write(i+ “ ” );i=cd1.count( ); 1using System; class StringDe public void f(string s) for (int j=0;js.Length;j+=2)Console.Write(sj);return; public static void Main( ) string str1=“中華人民共和國(guó)于一九四九年建立” ; StringDe ob=new StringDe( );ob.f(str1); 2using System;delegate void MyEventHandler();class MyEvent public event MyEventHandler activate; public void fire() if(activate!=null) activate(); class X int id;public X(int x) id=x/2;public void Xhandler( ) Console.WriteLine( id ); class EventDemo static void Main() MyEvent evt=new MyEvent(); X x1=new X(8); X x2=new X(16);X x3=new X(0);evt.activate+=new MyEventHandler(x1.Xhandler);evt.activate+=new MyEventHandler(x2.Xhandler);evt.activate+=new MyEventHandler(x3.Xhandler); evt.fire(); 1using System; class exception static void Main() for(int i=0;i0) return x-; else return 0; class Test static void Main( ) A a=new A(9 ); int j=a.F( ); while (j0) Console.Write(“0t ”, j*j );j=a.F( ); 1using System; class StringDe public void f(string s) for (int j=0;js.Length;j+=2)Console.Write(sj);return; public static void Main( ) string str1=“中華人民共和國(guó)于一九四九年建立” ; StringDe ob=new StringDe( );ob.f(str1); 2using System;delegate void MyEventHandler();class MyEvent public event MyEventHandler activate; public void fire() if(activate!=null) activate(); class X int id;public X(int x) id=x/2;public void Xhandler( ) Console.WriteLine( id ); class EventDemo static void Main() MyEvent evt=new MyEvent(); X x1=new X(8); X x2=new X(16);X x3=new X(0);evt.activate+=new MyEventHandler(x1.Xhandler);evt.activate+=new MyEventHandler(x2.Xhandler);evt.activate+=new MyEventHandler(x3.Xhandler); evt.fire(); 1 using System; class
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 風(fēng)險(xiǎn)應(yīng)對(duì)策略的選擇試題及答案
- 高考語(yǔ)文考場(chǎng)應(yīng)用試題及答案
- 湖北省咸寧市咸安區(qū)2025年八下數(shù)學(xué)期末統(tǒng)考試題含解析
- 制定個(gè)人學(xué)習(xí)與發(fā)展路徑計(jì)劃
- 細(xì)分市場(chǎng)的品牌定位研究計(jì)劃
- 提升領(lǐng)導(dǎo)力的實(shí)踐方法計(jì)劃
- 計(jì)算機(jī)科學(xué)專業(yè)進(jìn)階學(xué)習(xí)策略試題及答案
- 計(jì)算機(jī)輔助翻譯(CAT)軟件應(yīng)用試題及答案
- 2024年陜西科技大學(xué)輔導(dǎo)員考試真題
- 風(fēng)險(xiǎn)管理中的人才培養(yǎng)與發(fā)展試題及答案
- 康養(yǎng)休閑旅游服務(wù)基礎(chǔ)知識(shí)單選題及答案解析
- 公司師徒制、導(dǎo)師制管理辦法(完整版方案)
- 解剖學(xué)公開課課件內(nèi)分泌
- 家族財(cái)富管理
- 高中必修一英語(yǔ)單詞湘教版
- 森林防火預(yù)警監(jiān)測(cè)
- 銀屑病臨床病例討論
- 涉密人員審查備案登記表
- 園林綠化員工安全培訓(xùn)
- 蛙泳教學(xué)課件教學(xué)課件
- 高層建筑汽車吊吊裝作業(yè)方案
評(píng)論
0/150
提交評(píng)論