views:

54

answers:

3

Hi folks, is it possible to store multiple datatypes in an array, if not, what could the reason be?

TIA

+1  A: 

You can store anything you like in an array of objects, but doing so makes me wonder about your design.

John Saunders
+4  A: 

Yes.

You can make an object[] and put anything you want inside of it.

However, you probably shouldn't.
What are you trying to do?

SLaks
not trying to implement it but was curious to know if it was possible.Thanks.
SoftwareGeek
+1  A: 

If you declare your array as an array of object then, yes you can store anything in it. You'll have to cast to the desired type when you use it though. I think you really need to understand the concept of type-safety to get your head around why this is a bad idea in most languages.

http://en.wikipedia.org/wiki/Type_safety

spender