日期:2014-05-18 浏览次数:21221 次
private void button2_Click(object sender, EventArgs e) { int _index = 2;//相隔几位数 int[] Tel = new int[6]; Tel[0] = 12; Tel[1] = 16; Tel[2] = 43; Tel[3] = 665; Tel[4] = 23; Tel[5] = 1; ArrayList arrlist = new ArrayList(); for (int i = 0; i < 2; i++) { arrlist.Add(Sum(Tel,_index,i)); } foreach (var item in arrlist) { MessageBox.Show(item.ToString()); } } private int Sum(int[] tel,int _index,int starIndex) { int sum = 0; for (int i = starIndex; i < tel.Length; i += _index) { sum += tel[i]; } return sum; }