Variables in a loop

前端 未结 9 1554
眼角桃花
眼角桃花 2020-12-19 18:32

I was wondering whether there\'s a way in a \"for\" loop to assign a value to a string variable named according to its index number?

let\'s say I have 3 string varia

9条回答
  •  悲哀的现实
    2020-12-19 19:10

    can you use an array? or list type?

    string[] messages = new string[3];
    for (int i = 1; i <=3; i++)
     {
       messages[i] = "blabla" + i.ToString();
     }
    

提交回复
热议问题