开发者

c# basic formatting question

If I wanted to swap out part of a statement with开发者_StackOverflow a variable i.e.

tempCube.transform.parent = row(var would need to go here ie an int that is iterated with a for loop).transform;

How would I write this. Sorry for the really basic question, I have been using other languages too long and now I have gone back to c# I have almost forgotten everything I had learned.

"(i)" is the bit I want to swap out with a variable

eg

for(int i = 1; i <= 3; i++){ print row*(i)*.transform; }

Console:

(1,2,3) (2,3,4) (4,5,6)


You mean like:-

row1.transform;
row2.transform;
row3.transform;
...

If so, no, you can't replace that text at runtime. You should use a collection. Ideally make an IEnumerable out of them and use foreach:-

foreach (var x in new { row1, row2, row3 ... })
{
  x.transform;
}


I am not sure what you mean, i hope you want to specify the index, is this what you are looking for (index is the int you mentioned)

tempCube.transform.parent = row[index].transform;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜