Passsing an array from derived name

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

I have a situation where I have a method that I need to call. One of
the parameters of this method is a string[]. There are potentially
several string arrays that I could pass. Based on other information,
I can derive the name of the string array to pass to the called
method. But I can't figure out how to take the derived array name (a
string) and use it to get the actual string[] having that name to pass
as a paramater.

Any help appreciated!

~ Rick
 
There are probably better ways to do this. Can't you just do

If SomeCondition then PassInStringA
If SomeOtherCondition then PassInStringB
....
etc
 
What I'm trying to do is something like the following:

public void myFunction( string s1, string s2 )
{
// Assume s1 == "StoreArray" and s2 == "1"
// Also assume I have previously defined an array named
"StoreArray1"

string arrayName = s1 + s2; // arrayName == "StoreArray1"
myOtherFunction( //the array named "StoreArray1" );
...
}

I don't want to have to compare string literals. I would like to find
a way to pass the array named "StoreArray1" as an argument to a called
method. In other words, I'd like to take a name of an array which I
derive from other information, and get access to the array of that
name so that I can pass it as a method argument.

Thanks!

~ Rick

Michael Culley said:
There are probably better ways to do this. Can't you just do

If SomeCondition then PassInStringA
If SomeOtherCondition then PassInStringB
...
etc

--
Michael Culley


Rick said:
I have a situation where I have a method that I need to call. One of
the parameters of this method is a string[]. There are potentially
several string arrays that I could pass. Based on other information,
I can derive the name of the string array to pass to the called
method. But I can't figure out how to take the derived array name (a
string) and use it to get the actual string[] having that name to pass
as a paramater.

Any help appreciated!

~ Rick
 
Back
Top