0
I am studying DDD and Webapi and as I find difficulties, I research and try to solve. Of course, sometimes I come across simple things for some here and I can’t get it right away.
Sometimes I even understand what has to be done, but I don’t know how to do it, as is the case now. With Console project, I did, but I switched to a Windows Form and I’m having this difficulty.
I need to fill a Listbox as a result of a lambda Foreach resulting from a list of a Predicate. The question is in Foreach, so:
private void button1_Click(object sender, EventArgs e)
{
string[] teste = new string[] { "um", "dois", "tres", "quatro", "cinco" };
Predicate<string> p = objetoTeste => objetoTeste.Length >= 4;
var i = from items in teste
where (p(items))
select (items);
i.ToList().ForEach(listBox1.Items.Add()**==>> Dúvida aqui**);
/*foreach (var item in teste)
{
listBox1.Items.Add(item);
}*/
}
The question is how to call the ListBox1.Items.Add()
and fill it inside the foreach