Passsing an array from derived name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    #1

    Passsing an array from derived name

    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
  • Michael Culley

    #2
    Re: Passsing an array from derived name

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

    If SomeCondition then PassInStringA
    If SomeOtherCondit ion then PassInStringB
    ....
    etc

    --
    Michael Culley


    "Rick" <rbrown@allstat e.com> wrote in message news:500a18df.0 311051157.5e596 0ac@posting.goo gle.com...[color=blue]
    > 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[/color]


    Comment

    • Rick

      #3
      Re: Passsing an array from derived name

      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
      "StoreArray 1"

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

      I don't want to have to compare string literals. I would like to find
      a way to pass the array named "StoreArray 1" 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" <mculley@NOSPAM optushome.com.a u> wrote in message news:<uXh11L$oD HA.3612@TK2MSFT NGP11.phx.gbl>. ..[color=blue]
      > There are probably better ways to do this. Can't you just do
      >
      > If SomeCondition then PassInStringA
      > If SomeOtherCondit ion then PassInStringB
      > ...
      > etc
      >
      > --
      > Michael Culley
      >
      >
      > "Rick" <rbrown@allstat e.com> wrote in message news:500a18df.0 311051157.5e596 0ac@posting.goo gle.com...[color=green]
      > > 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[/color][/color]

      Comment

      Working...