In C#, can I store multiple data types in an ArrayList? Like;
myArrayList.Add(false);
myArrayList.Add("abc");
myarrayList.Add(26);
myArrayList.Add(obj);
I know i can make a DataTable or a class for it.
But, please let me know: is this possible? And if so, what are it's De-merits of being a collection class?
Yes you can store like this
ArrayList aa = new ArrayList();
aa.Add(false);
aa.Add(1);
aa.Add("Name");
ArrayList belongs to the days that C# didn't have generics. It's deprecated in favor of List. You shouldn't use ArrayList in new code that targets .NET >= 2.0 unless you have to interface with an old API that uses it.
ArrayList vs List<> in C#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With