100% Guaranteed Results


PCS – Figure out how to remove items from a list while searching a list See this code, try it, it will throw an exception. Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

Try to write some code to make this logic work

public class Person { public string name; public int age;
}

internal class Test {
static void Main(string[] args) { List<Person> pList = new List<Person> { new Person(){name=”Jim”, age=45}, new Person(){name=”Joe”, age=25}, new Person(){name=”Jack”, age=35}, new Person(){name=”Jill”, age=20}, new Person(){name=”Jeff”, age=30}, new Person(){name=”Jenn”, age=55}
};
foreach (var p in pList) { if (p.age < 30) { pList.Remove(p); — this will crash
}
}
}
}

Reviews

There are no reviews yet.

Be the first to review “PCS – Figure out how to remove items from a list while searching a list See this code, try it, it will throw an exception. Solved”

Your email address will not be published. Required fields are marked *

Related products