1.switch - if ...else if...
switch(表达式)
{
case 值:
。。。。。
break;
case 值:
。。。。。
break;
default:
。。。。。
break;
}

2.while -- for
int i = 0;//变量初化。
while(循环条件)
{

//循环体
//i++;//状态改变。
}
do...while();

foreach(元素类型 变量 in 集合或数组)
{
}

3.锯齿数组——数组的数组
定义:
a.定义数组的数组:
int[][] a = new int[3][];
b.定义一维数组:
int[] b1 = new int[4]{1,2,3,4};
int[] b2 = new int[3]{5,6,7};
int[] b3 = new int[5]{9,10,11,12,13};
c.把一维数组加到数组的数组中去
a[0] = b1;
a[1] = b2;
a[2] = b3;

使用:
a[行][列] = 。。。
a[行][列]

a.Length == ??? 3
a[0].Length = ????? 4

4.集合:
(1)链表——每个存储的值都会分配一个索引号,通过索引号可对每个元素赋值或取值。
弱类型:
using System.Collection;
ArrayList list = new ArrayList();

强类型:
using System.Collection.Generic;
List<类型> list = new List<类型>();

list.Clear();
list.Add(value);
list.Insert(索引号,value);
list.RemoveAt(索引号);
list.Count;

(2)哈希表——每个元素都由两部分组成,一部分叫key,一部分叫value
弱类型:
using System.Collection;
Hashtable table = new Hashtable();

强类型:

using System.Collection.Generic;
Dictionary<类型,类型> dic = new Dictionary<类型,类型>();

dic.Clear();
dic.Add(key,value);
dic.Remove(key)
dic.Count;

5.递归——自己调自己 

int Add(int a)
{
int b = Add(a+1);
Console.WriteLine(b);
}

void 讲故事()
{
Console.Write("从前。。。,老和尚说:");
讲故事();
}

void 找子级文件夹(当前文件夹)
{
if(当前文件夹下没有子文件夹)
{
return;
}
找子级文件夹(当前文件夹下的第一个子文件夹);
}

(二)枚举:使用枚举来替代一些难以记忆的整数。
枚举和整数之间可以相互强制转换。
定义:
enum 枚举名
{
成员名[=整数],
成员名[=整数],
成员名[=整数],
....
成员名[=整数]
}

使用:
枚举名.成员名

posted on 2015-05-19 20:12  浅笑瑾年  阅读(145)  评论(0编辑  收藏  举报