[RESOLVED][C#] Multi Variable Array/List?

Started by G_G, August 24, 2010, 11:32:48 am

Previous topic - Next topic

G_G

August 24, 2010, 11:32:48 am Last Edit: August 24, 2010, 11:42:03 am by game_guy
Basically what its like in Ruby. Ruby can have an array, and you can place anything in that array. Integers, strings, objects. Their not binded to just one type of array. So basically, I'm curious if its possible to create an array or list in c# that can hold multiple object types.


G_G

Even though thats in visual basic, I figured it out. Dunno why I didn't think of it. Just make a list or an array with object set as the argument or whatever.
List<object> multi_data_array = new List<object>();
object[] multi_data_array2 = new object[array_size];


Thanks stripe. Resolved.

Blizzard

Though I wouldn't recommend using multi-type arrays. It's a pretty bad and dirty concept in itself. Used properly types arrays whenever you can. In fact, there is no need for multi-type arrays if the code was structured well. Only badly structured code needs multi-type arrays of types that are completely different (rather than an array with instances that share the same base class up to some point).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Well basically I'm converting data. I'm sure you've looked how sloppy the pokemon starter data is. Some of the config files just have long huge lines. I'm sure I could find a better way of doing this but this seems to work just fine.