我正在尝试使用字符串来标识我的数组。我有一个方法,它接受字符串作为参数,我想使用该字符串的值来识别要编辑的数组。
class Test{
static string[] myNums = { "1","2","3","4" };
static string[] myNames = { "Bill", "Peter", "Michael", "Samir" };
public Test
{
int choice = Int32.Parse(Console.ReadLine());
if(choice == 1)
ProcessAccount("myNums");
else if(choice == 2)
ProcessAccount("myNames");
}
public void ProcessAccount(string id)
{
//This is where I want to identify the array to modify
//based on the ID so I do not have to do separate lines of code
id[0] = "PAST DUE"; //something like this
}
}
有没有办法做到这一点?