Z
Z
Zefirot2021-07-27 10:45:52
C++ / C#
Zefirot, 2021-07-27 10:45:52

Is it possible to set variables inline?

In php, this was definitely possible, it looked something like this ${"Test".$a} which could be equal to both $Test1 and $Test2, etc.
I also need an assignment like this, so far I'm doing this

public GameObject SelectTest1;
public GameObject SelectTest1;
public GameObject SelectTest1;
.......................
GameObject SelectedObject= null;
switch(v){
  case "Test1": SelectedObject = SelectTest1; break;
  case "Test2": SelectedObject = SelectTest2; break;
  case "Test3": SelectedObject = SelectTest3; break;

How to simplify it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question