In Lua and Javascript you can put different datatypes in an array. Bools; Strings; Ints and such. But I see that in C#, the arrays look something like
string[] keysPressed ={};
So... Can I not put different datatypes in an array? Yes I know its obvious that you cant in that line. But is there like some other way I can create an array that supports different things?
object[] anythingYouWant = new object[] { "Hello", 42, new Dictionary<string,int>() };- which is what LUA (or JavaScript, etc.) is effectively doing, by not having static typing. However, this throws away static type information and usually makes it more difficult to consume the data. To solve this in the C# (or, statically typed way) requires going back and re-examining the goal: and then solving it as suited for that language, not another one. (There is alsodynamicin C#, but I hate to "suggest" that as a core approach/concept.)object[]'works' because every value in C# "is an inhabitant of the Object type" or "can be treated-as an Object".