Foreach listbox item c#
Ngày đăng:
31/12/2021
Trả lời:
0
Lượt xem:
202
I'm pretty sure this has worked before in some code I have written, not sure what I am missing here. The following code does not change the string values in my list. Why? var items = listBox1.Items.Cast().ToList(); items.ForEach(item => item = (!chkBox1.Checked) ? "move " + item : "move -check " + item);EDIT : Just to clarify, the list remains the same as when it was created. EDIT : Apologies, the items list (listBox1.Items) contains alphanumeric strings as follows. J00123456 J00123344 J00123458 Also, just to confirm, I have successfully done this with a custom list of T (shown below), which is why I thought it would work here. var tapes = new List(); ... //Populated list tapes.ForEach(x => x.vItem = "tapelib 3592 -eject " + x.vItem); //Works here |