首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

问一下数组的有关问题!

2012-01-23 
问一下数组的问题!!C# code string shuzi ,04,06,19,23,25,28,06,03,04,13,24,31,32,04,07,11,15,17,21

问一下数组的问题!!

C# code
 string shuzi = ",04,06,19,23,25,28,06,03,04,13,24,31,32,04,07,11,15,17,21,26,14,01,12,14,17,22,25,11,02,04,06,15,17,30,14";        //假如现在有这样一组数字,我想得到每7个数字为一组,例如第一组为:04,06,19,23,25,28,06        //我想在一个for循环里面得到这样        int h1, h2, h3, h4, h5, h6, h7;        for()        {        //每循环一次,得到一组,            h1=;        h2=;        h3=;        h4=;        h5=;        h6=;        h7=;        }


[解决办法]
Math.Round(Decimal d)函数,向上取整啊,比如Math.Round(0.666),Math.Round(Decimal d)用它处理后,等于1
[解决办法]
class Program
{
static void Main(string[] args)
{
char[] separator = { ',' };
var str = ",04,06,19,23,25,28,06,03,04,13,24,31,32,04,07,11,15,17,21,26,14,01,12,14,17,22,25,11,02,04,06,15,17,30,14";
var arr = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
for (var i = 0; i < arr.Length; i += 7)
{
var group = arr.Skip(i).Take(7).ToArray();
Debug.WriteLine(string.Join(",", group));
}

}
}

热点排行