Chapter 10 数组和集合

上一篇 / 下一篇  2012-04-15 00:14:15 / 天气: 大风 / 心情: 高兴 / 个人分类:C# 2010 学习

数组
1 初始化数组
int[] pins = new int[4] {9,3,7,2};
int[] pins = {9,3,7.2};
2 结构数组的初始化
Time[] schedule = {new Time(12,30),new Time(5,30)};
3 遍历数组
int[] pins = new int[4]{9,3,7,2};
for(int index = 0; index <pins.length; index++)
{
   int pin = pins[index];
   Console.WriteLine(pin);
}
foreach(int pin in pins)
{
   Console.WriteLine(pin);
}
4 创建隐式类型数组
var names  = new[]{"fanzhikang","wangtao"};
5 拷贝数组
int[] pins = new[] int{9,3,5,2};
int alias = pins;
foreach(int alia in alias)
{
  Console.WriteLine(alia);
}
51Testing软件测试网!u%M,^\L\`#~y
51Testing软件测试网c1Z9J x:_;[j6XU
int[] pins = new int[]{9,3,5,2};
int[] copy = new int[pins.length];
for(int i =0 ; i<pins.length; i++)
{
    copy[i] = pins[i];
}
51Testing软件测试网 n\I1JN:L1B
pins.copyto(copy,0);
int [] copy = (int[])pins.clone();
Array.copy(pins,copy,copy.length);

5O Tl-l n%D`5X+U0

TAG:

 

评分:0

我来说两句

日历

« 2024-04-26  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 10936
  • 日志数: 24
  • 建立时间: 2011-08-24
  • 更新时间: 2012-07-23

RSS订阅

Open Toolbar