动态生成的变量名 [英] Generating variable name dynamically
本文介绍了动态生成的变量名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道是否有在可以动态例如可以产生像一个数组变量名电流编程语言的任何方法。
i just want to know is there any method in current programming languages where a variable name like an array can be generated dynamically for example.,
for(i=1;i<10;i++)
{
int a <concatenation operator> i = <some logic on variable i>;
printf("the value generated in the logic is %d",a <concatenation operator> i);
}
我知道有阵列的理念,在类似的方式,但我只是想知道,如果这个存在于任何编程语言。
i know there is a concept of arrays in the similar way but i just want to know if this exists in any programming language.
在此先感谢....
推荐答案
EVAL也许,但我不会用它。
eval perhaps, but I wouldn't use it.
要添加到乔恩斯基特的评论,做这样的事情是可能的,但不明智的原因是多方面的。
To add to Jon Skeet's comment, doing this sort of thing may be possible but is ill-advised for many reasons.
这篇关于动态生成的变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文