Dovberman
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["EvalItem ID"].ToStr ing();
parrEvalItems[intRow, 2] = prdrGetEvalItems["EvalItem Name"].ToS tring();
parrEvalItems[intRow, 3] = prdrGetEvalItems["EvalItem Descr"].To String();
parrEvalItems[intRow, 4] = prdrGetEvalItems["EvalItem Crit"].ToS tring();
parrEvalItems[intRow, 5] = prdrGetEvalItems["EvalSymb olLink"].T oString();
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
//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["EvalItem
parrEvalItems[intRow, 2] = prdrGetEvalItems["EvalItem
parrEvalItems[intRow, 3] = prdrGetEvalItems["EvalItem
parrEvalItems[intRow, 4] = prdrGetEvalItems["EvalItem
parrEvalItems[intRow, 5] = prdrGetEvalItems["EvalSymb
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I was hoping it was a simple syntx error.