troubleshooting Question

How to build and return an array C#

Avatar of Dovberman
DovbermanFlag for United States of America asked on
ASP.NET.NET ProgrammingMicrosoft Development
2 Comments1 Solution509 ViewsLast Modified:
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();

            }  // 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.

Sr. Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros