问题描述
我有一个查询,我想将结果作为数组插入并将其插入单个数组中
我试图在每一天选择不同的行,一周。
ex。
I have a query and I want to insert results as an Arrays and insert it in a single Array
I'm trying to get selected Distinct Rows in each day, for a Week.
ex.
{{A,B,C,D},{A,C,D},{A,B}}
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
myItems = new Itemset(); //this is where I store items in 1 array
myDb = new ItemsetCollection();// this is where I want to store multiple
//arrays
var tmp = reader["Fruit"];
if (tmp != DBNull.Value)
{
ListBox1.Items.Add(tmp.ToString());
}
foreach (var items in ListBox1.Items)
{
myItems.Add(items.ToString());
}
foreach (var items in myItems)
{
myDb.Add(new Itemset() {items.ToString()});
}
lbList.Text = string.Join(",\n", myItems.ToArray());
}
}
我的代码的结果如下:
苹果,橘子,葡萄,柠檬,苹果,葡萄,苹果,橙子,柠檬。
它远远超出了我的想象。
{{Apple,Orange,Grapes,Lemon},{Apple,Grapes},{Apple,Orange,Lemon}}
我需要一个C#代码在一个数组中插入一组数组。
我试过foreach将它存储在数组中。
我需要的最终结果
The result from my code is this:
Apple, Orange, Grapes, Lemon, Apple, Grapes, Apple, Orange, Lemon.
Its so far from what I want it to become.
{{Apple, Orange, Grapes, Lemon}, {Apple, Grapes}, {Apple,Orange, Lemon}}
I need a C# code to insert a set of arrays in a single Array.
I tried foreach to store it in array.
THE FINAL RESULT I NEED
[Week] | [AllFruits]
1 | {Apple, Orange, Grapes, Lemon},{Apple, Figs, Lemon}, {Apple, Figs, Grapes, Strawberry},{Grapes, Lychee, Strawberry},{Apple,Orange,Grapes},{Apple,Figs,Grapes,Lychee}
我希望你明白我想要处理什么。
我研究了大部分需要的东西信息只是为了完成这个过程,但我仍然缺少/错过了一些重要的部分。
I hope you understand what I want to process.
I researched most of the needed information just to do this process but still I lack/miss some important part.
推荐答案
这篇关于如何在Array中获取数组。 [续]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!