当前位置:首页 > C#教程 > C#进阶

C#进阶

C#不安全的代码

8

usingSystem;namespaceUnsafeCodeApplication{classProgram{staticunsafevoidMain(string[]args){intvar=20;int*p=&var;Cons

C#条件指令

8

#defineDEBUG#defineVC_V10usingSystem;publicclassTestClass{publicstaticvoidMain(){#if(DEBUG&&!VC_V10)Console.Writ

C#不安全代码检索数据值

6

usingSystem;namespaceUnsafeCodeApplication{classProgram{publicstaticvoidMain(){unsafe{intvar=20;int*p=&var;Console.W

C#使用委托

6

usingSystem;usingSystem.IO;namespaceDelegateAppl{classPrintString{staticFileStreamfs;staticStreamWritersw;//delegatedecl

C#重载和非重载运算符

9

usingSystem;namespaceOperatorOvlApplication{classBox{privatedoublelength;//Lengthofaboxprivatedoublebreadth;//Breadthofa

C#数组零索引

7

usingSystem;namespaceArrayApplication{classMyArray{staticvoidMain(string[]args){int[]n=newint[5];inti,j;/*begingsfromind

C#抽象与虚拟动态多态

7

usingSystem;namespacePolymorphismApplication{classShape{protectedintwidth,height;publicShape(inta=0,intb=0){width=a;heig

C#访问数组元素

9

usingSystem;namespaceArrayApplication{classMyArray{staticvoidMain(string[]args){int[]n=newint[10];/*nisanarrayof10intege

C#Stack类

7

usingSystem;usingSystem.Collections;namespaceCollectionsApplication{classProgram{staticvoidMain(string[]args){Stackst=ne

C#运算符重载

11

usingSystem;namespaceOperatorOvlApplication{classBox{privatedoublelength;//Lengthofaboxprivatedoublebreadth;//Breadthofa

C#其他运算符

5

usingSystem;namespaceOperatorsAppl{classProgram{staticvoidMain(string[]args){/*exampleofsizeofoperator*/Console.WriteLin

C#嵌套循环

10

usingSystem;namespaceLoops{classProgram{staticvoidMain(string[]args){/*localvariabledefinition*/inti,j;for(i=2;i<100;

C#使用索引器

8

usingSystem;namespaceIndexerApplication{classIndexedNames{privatestring[]namelist=newstring[size];staticpublicintsize=10

C#for循环

10

usingSystem;namespaceLoops{classProgram{staticvoidMain(string[]args){/*forloopexecution*/for(inta=10;a<20;a=a+1){Cons

C#do...while循环

4

usingSystem;namespaceLoops{classProgram{staticvoidMain(string[]args){/*localvariabledefinition*/inta=10;/*doloopexecutio

C#字符串包含字符串

7

usingSystem;namespaceStringApplication{classStringProg{staticvoidMain(string[]args){stringstr="Thisistest";if(