syntax help for using .Length with a string variable
<p>I am using multiple case statements/arrays although I am only posting 1 for clarity.</p>

<p><code>typeSelected</code> is set from a <code>combobox.SelectedIndex</code> value and is used to select the case to run.</p>

<p>In the case I set a variable <code>typeUnits</code>, in the example, to the string <code>"lengthUnits"</code>, which is the name of the array with 3 items in.</p>

<p>I want the for loop to run using <code>lengthUnits.Length</code> but the code is processing this as <code>typeUnits.Length</code>, can someone please point me in the right direction?</p>

<p>I have tried <code>typeUnits.Text</code> <code>typeUnits.ToString()</code> <code>typeUnits.Content</code> but nothing works.</p>

<pre><code>string[] lengthUnits = new string[] {"Feet", "Miles", "Inches"};

int typeSelected = cmb_Select_Type.SelectedIndex;

        switch (typeSelected)
        {
            case 1: typeUnits = "lengthUnits"; break; //Length Units
            default: break;
        }

            for (int i = 0; i &lt; typeUnits.Length; i++)
            {
                cmb_Select_From.Items.Add(typeUnits[i]);
            }
</code></pre>

<p>If I can't get this to work then I need to write the for loop multiple times for each condition, I was trying to avoid that by just writing it once.</p>