Link to home
Create AccountLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

How to build and return an array C#

I get a complie error when I try to return an array from a procedure.

//Build and Return the array
string[,] arrEvalItems = FillArray(rdrGetEvalItems);
//Cannot implicitly convert type 'string[]' to 'string[*,*]'

private string[] FillArray(SqlDataReader prdrGetEvalItems)
    {
        string[,] parrEvalItems = new string[12, 6];
        if (prdrGetEvalItems.HasRows)
        {
            //Read EvalItems

            int intRow = 1;
            while (prdrGetEvalItems.Read()) // using read() method to read all rows one-by-one
            {
                // Read the col values into the arrEvalItems array

                //for intRow =
                parrEvalItems[intRow, 1] = prdrGetEvalItems["EvalItemID"].ToString();
                parrEvalItems[intRow, 2] = prdrGetEvalItems["EvalItemName"].ToString();
                parrEvalItems[intRow, 3] = prdrGetEvalItems["EvalItemDescr"].ToString();
                parrEvalItems[intRow, 4] = prdrGetEvalItems["EvalItemCrit"].ToString();
                parrEvalItems[intRow, 5] = prdrGetEvalItems["EvalSymbolLink"].ToString();

                intRow++;
            }  // End (rdrGetEvalItems())
           
            prdrGetEvalItems.Close(); // closing SqlDataReader
         }
        return parrEvalItems; // return the array that ws built.
//Cannot implicitly convert type 'string[*,*]' to 'string[]'
   
    }      

I am trying to determine the correct syntax.
Please help.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Misbah
Misbah
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Dovberman

ASKER

Thanks,

I was hoping it was a simple syntx error.