c# - Unity3D Dynamic variable declare -


this question has answer here:

i'm having trouble when trying make dynamic variable example:

→ public type_unknow mytype;  void awake(){ //i want make mytype spriterenderer or image or int float etc.  } 

i appreciate replies.

this called implicit type, when want have declare var type variable. var keyword tells compiler infer type of variable expression on right side of initialization statement.

example:

// compiled int var = 5;  // s compiled string var s = "hello";  // compiled int[] var = new[] { 0, 1, 2 };  // expr compiled ienumerable<customer> // or perhaps iqueryable<customer> var expr =     c in customers     c.city == "london"     select c;  // anon compiled anonymous type var anon = new { name = "terry", age = 34 };  // list compiled list<int>                              var list = new list<int>(); 

source


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -