Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List with different object types?

Can I have a List containing one string and two numbers? Or I can only have one type of element?

like image 771
Voldemort Avatar asked Dec 04 '22 23:12

Voldemort


1 Answers

If that's the kind of functionality you want, then I would look at the non-generic System.Collections.ArrayList class.

Update

For those of you who aren't going to read the huge comment chain...it looks like Adam Robinson is on to something using List<object> over ArrayList. Both will work but on large collections it seems like List<object> is measurably faster than ArrayList.

like image 168
Justin Niessner Avatar answered Jan 04 '23 14:01

Justin Niessner