Combine Value to "word"

I’m an amature programmer in Unity and am using C# to make a gun. What I am trying to do is combine a “word” to a value. So for example

GameObject light = transform.parent.parent.Find("L"..level);

in which “L” is the word, ‘level’ is the value, and … represents how I would like them to be combined. So if level = 1, then it would ammount to ‘L1’. If someone could give me a simple answer on how to do that I would be appreciative.

Consider using string.Format() for example: string word = "L"; int level = 1; string objectName = string.Format("{0}{1}", word, level.ToString());

1 Answer

1

There are many different ways the achieve that, one of the easiest ways in your case would be to simply use a +: GameObject light = transform.parent.parent.Find(“L” + level);