Variables in a loop

前端 未结 9 1569
眼角桃花
眼角桃花 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:09

    You can also do it without the index:

        string[] Messages = { "Tom", "Dick", "Harry" };
    
        foreach (String Message in Messages)
        {
            Response.Write("Hello " + Message + "
    "); }

提交回复
热议问题