C#入门基础02

1  常量     const    数据类型   常量名称=常量值

2  枚举    关键字:enum   [public]  enum 名称 { 值1,值2,值3}

3  变量    [修饰符] 变量类型 变量名称;

4  结构   关键字:struct   [public]  struct  结构名称   {  字段1;字段2;字段;}

例:  

             Public   enum  Gender

            {      男,女    } 

             public   struct  Person

             {

                      Public  int  age;

                      Public  int  height;

                      Public  string  name;

                      Public  Gender  gender;

           } 

 

5   数组    数组类型[]  数组名称=new 数组类型[数组长度]

                 数组类型[]  数组名称=new 数组类型[];

                 数组类型[]  数组名称=new  数组类型[数组长度]{值1,值2,值3};

                 数组类型[]  数组名称=new  数组类型[]{值1,值2,值3};

 

6  数组反序交换位置  

 Int[]  a=new int[]{1,2,3,4,5,6};

for(int i=0;i<a.length/2;i++)

{

         Int  s=a[i];

         a[i]=a[a.length_1_i];

         a[a.length_1_i]=s;

}  .    

 

7   运算符   +    _  *    /

    逻辑运算符   &&    ||     !

    复合运算符  +=    _=

    关系运算符  >=  <=

 

8    return  的作用:退出当前循环,终止程序

     Continue    :跳出当时循环,继续下一轮循环

 

9  if     if...else    if...if...   if...else  if...

 

10  冒泡法排序

      Int[]   a=new  int[]{1,9,6,3,8};

      For(int  i=0;i<a.length;i++)

      {

              For(int j=0;j<j.length_1_i;J++ )

             {

                    If(a[j]<a[j+1] )

                   {

                           交换位置

                    }

             }

      }

 

 

 

本文由作者原创,如有引用、转载请注明出处。(如有不正之处,欢迎指出,相互交流,谢谢!)

posted on 2015-03-22 18:03  拯&救  阅读(72)  评论(0编辑  收藏  举报