是否有可能在asp.net c#中使用另一个变量引用变量/数组? EG。在变量中使用asp.net c存储变量名称#
alfaromeo = new string[] {"lots of stuff"};
astonmartin = new string[] {"lots of stuff"};
audi = new string[] {"lots of stuff"};
bentley = new string[] {"lots of stuff"};
bmw = new string[] {"lots of stuff"};
etc
string targetArray = "audi";
for(int i=0; i<targetArray.Length; i++){
// do stuff with tha array
}
有一个原因,数组都被称为不同的名称,我没有使用多维数组来引用它们。
可以这样做,还是我需要使用某种查找数组引用它们?
在此先感谢。
'串targetArray =“audi”;'这是一个'字符串'还是'字符串[]'? – Marco 2014-10-27 10:01:59
一个字符串。这将是一个刚刚存储我想要使用的数组名称的地方,除非您看到比我更合乎逻辑的事情。这是非常可能的:) – 2014-10-27 10:04:27