Dynamic variable in C#?

前端 未结 5 661
猫巷女王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:20

    Not sure if this works with local variables (and most likely it doesn't since they're stored as indexes), but you could access class properties through reflection.

提交回复
热议问题