Dynamic variable in C#?

前端 未结 5 660
猫巷女王i
猫巷女王i 2020-11-30 12:00

Is it possible to use a dynamic variable (not sure about naming) in C#?

In PHP, I can do

$var_1 = \"2\";
$var_2 = \"this is variable 2\";

$test = ${         


        
5条回答
  •  北海茫月
    2020-11-30 12:26

    You are not looking for simple arrays?

    string[] myArray = new string[2];
    
    myArray[0] = "2";
    myArray[1] = "this is variable 2"
    

    Otherwhise dictionary is the way to go.

提交回复
热议问题