码迷,mamicode.com
首页 > 其他好文 > 详细

2014.8.26集合.贪吃蛇

时间:2014-08-26 22:40:56      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   strong   for   文件   ar   2014   

(一)更改.NET Framework版本、更改.exe图标、更改特性值

1.更改.NET Framework版本:考虑到把.exe文件发给别人,别人的电脑.NET Framework版本的问题,有时需要对Framework版本进行更改,如下图:

  右键点击项目名称,属性,选择框架版本,最后保存

bubuko.com,布布扣

bubuko.com,布布扣

2.更改.exe文件图标

找到.exe路径,依然右键属性,选择图标路径,保存

bubuko.com,布布扣

bubuko.com,布布扣

3.更改标题,标签,作者,公司,等等。找到Properties文件夹中的AssemblyInfo.cs文件,里面的特性值都可以更改

bubuko.com,布布扣 bubuko.com,布布扣

(二)集合

1.定义    ArrayList a = new ArrayList();

2.显示    for(;;)

3.取值操作  a[i]

 赋值操作  a[i]=5;

4.其他操作

  取集合元素 count

  追加元素    add();

 

 1 int[] b = new int[5] { 10, 20, 30, 40, 50 };
 2 //集合
 3 ArrayList a = new ArrayList();
 4 a.Add(3);//增加元素
 5 a.Add(5);
 6 a.Add(12);
 7 Console.WriteLine(a.Count);
 8 
 9 a.RemoveAt(1);//移除
10 a.AddRange(b);//加一组,数组
11 a.Insert(0, 100);//插入
12 a.InsertRange(0, b);//在0的位置插入一组
13 
14 a.Clear();//全删
15 a.IndexOf(5);//找第几个值是在哪出现的
16 a.LastIndexOf(5);
17 
18 a.Reverse();//翻转
19 a.Sort();//升序排序,如果降序再加个翻转

 

(三)foreach

 1 int[] a = new int[5] { 10,20,30,40,50};
 2 string[] strs = new string[5] { "qwer", "asdf", "zxcv", "tyui", "ghjk" };
 3 foreach (int n in a)//读取,一般用来取值,比for循环效率要高
 4 {
 5     Console.WriteLine(n);
 6 }
 7 foreach (string s in strs)
 8 {
 9     Console.WriteLine(s);
10 }

(四)栈(Stack)、队(Queue)

 1 Stack s = new Stack();//栈——先进后出
 2 s.Push(5);//往里塞值
 3 s.Push(12);
 4 s.Push(7);
 5 while (s.Count > 0)
 6 {
 7     Console.WriteLine(s.Pop());//弹出
 8 }
 9 Console.WriteLine((int)s.Pop());
10 Console.WriteLine((int)s.Pop());
11 Console.WriteLine((int)s.Pop());
12 s.Clear();//清空
1 Queue q = new Queue();//队——先进先出
2 q.Enqueue(4);//进队
3 q.Enqueue(8);
4 //q.Dequeue();//出队
5 //q.Clear();//清空
6 while (q.Count > 0)
7 {
8     Console.WriteLine(q.Dequeue());
9 }

 

 

2014.8.26集合.贪吃蛇

标签:style   blog   http   color   strong   for   文件   ar   2014   

原文地址:http://www.cnblogs.com/zsmj001/p/3938258.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!