Avatar of Keith McElroy
Keith McElroy

asked on 

C# string array scope

The code below succeeds test 1, fails test 2.  How do I declare arrDataObject outside the if statement
so it is in scope for test 2?

            if(request.QueryString["dataobjects"] != null)
            {
                  string [] arrDataObject = request.QueryString["dataobjects"].Split(new Char [] {'~'}, StringSplitOptions.RemoveEmptyEntries);
                  response.Write("test 1" + arrDataObject[0] );
            }

response.Write("test 2" + arrDataObject[0] );
C#

Avatar of undefined
Last Comment
Keith McElroy

8/22/2022 - Mon