我有一個foreach循環數組:與陣列循環工作
StreamReader reader = new StreamReader(Txt_OrigemPath.Text);
reader.ReadLine().Skip(1);
string conteudo = reader.ReadLine();
string[] teste = conteudo.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in teste)
{
string oi = s;
}
行我讀包含像matriculation, id, id_dependent, birthday ...
幾場我有,用戶可以選擇他想要選擇至極字段CheckedListBox以及他想要什麼樣的順序,根據這個選擇並且知道陣列中每個值的順序(我知道第一個是matriculation
第二個是id
而第三個是name
),我怎麼能選擇一些字段,通過它值給某些變量,並根據checkedlistbox的順序對它們進行排序?希望我能清楚。
我嘗試這樣做:
using (var reader = new StreamReader(Txt_OrigemPath.Text))
{
var campos = new List<Campos>();
reader.ReadLine();
while (!reader.EndOfStream)
{
string conteudo = reader.ReadLine();
string[] array = conteudo.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries);
var campo = new Campos
{
numero_carteira = array[0]
};
campos.Add(campo);
}
}
現在,我如何可以運行在列表中,並從checkedlistbox
用戶選擇那些字段比較它的價值? 因爲如果我再比如類出{}
它的價值將是空的......
Person p = new Person();
string hi = p.numero_carteira; // null.....
你覺得'reader.ReadLine()。Skip(1);'是嗎?因爲它確實讓人煩惱。 – antonijn
你想要完成什麼? – MUG4N
不,根本不清楚。我得到你想要顯示來自文件的項目,並且你有一個checkedlistbox來選擇和訂購這些項目。由於您擁有列表中的項目,因此只需將列表中的項目與checkedlistbox中的項目進行比較,然後創建一個新列表,並按照正確的順序選擇項目,然後將該數據放入您的輸出中(ListView ?) –