简体   繁体   English

字符串到数组/变量集.NET Bingo

[英]String to Array / Var Set .NET Bingo

I have a set of thirty numbers in a DB which are all in one cell, separated by spaces. 我在数据库中有一组三十个数字,它们全部位于一个单元格中,并用空格分隔。 I am evaluating them as such: 我正在这样评估他们:

    <%# Eval("winning_numbers").ToString().Split(' ')[0]%>
    <%# Eval("winning_numbers").ToString().Split(' ')[1]%>
    <%# Eval("winning_numbers").ToString().Split(' ')[2]%>

And so forth, up to thirty (29). 依此类推,最多三十(29)。 This displays them all in a row. 这将它们连续显示。 The numbers are random up to 75, like in a bingo game. 就像在宾果游戏中一样,数字是随机最多75个。 What I would like to be able to do is to display them in a table, where if the number is between 01 and 15, it displays in the first row, 16-30 = second row, and so forth. 我想做的是将它们显示在表格中,如果数字在01到15之间,则它将显示在第一行中,而16-30 =第二行,依此类推。 Where I'm stuck mentally is that there aren't a finite amount of numbers in each tier - it is totally random. 我在头脑中陷入困境的是,每一层中没有数量有限的数字-这完全是随机的。 How can I do what I'm looking for? 我该怎么办?

You are looking for two-dimensional arrays, check this out: 您正在寻找二维数组,请检查以下内容:

If you have all of them items inside of a list then you can iterate through the list using a for loop 如果所有这些项都在列表中,则可以使用for循环遍历列表

for(int I = 0; I < numlist.Count; I++)
{
     //Inside the for loop we can check the number, and see what column it will fit into.
     if(1 <= I <= 15)
     {
          //The code to put the item into the respective list.
     }
     if(16 <= I <= 30)
     {
          //The code to put the item into the respective list.
     }
     etc...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM