I currently have the below code:
public int GetSeatInfoString(DisplayOptions choice, out string[] strSeatInfoStrings)
{ strSe
You have no final return before the method exits. You are exiting if there are no elements but you need a return at the end. If you are not interested in the value then why not set the return type to void?
You need to return an integer value according to your methods signature.
After the for loop is where a value should be returned.
You are only returning a value if count <= 0. Either you need to return a value after the for loop, or change the method signature to be void, depending on what you want the return value to represent.
If you want to return the array with the counts in, then change the return type to string[] and remove the out argument.
What value do you want to return from this function? I guess that you need to add this line to the end:
return i;
The error isn't anything to do with your out
parameter.
Your method
public int GetSeatInfoString(
DisplayOptions choice, out string[] strSeatInfoStrings)
is declared as returning an int
, and doesn't do this for all code paths.
You can add return strSeatInfoStrings.Length
at the end
public int GetSeatInfoString(DisplayOptions choice, out string[] strSeatInfoStrings)
{
strSeatInfoStrings = null;
int count = GetNumOfSeats(choice);
if ((count <= 0))
return 0;
strSeatInfoStrings = new string[count];
int i = 0;
for (int index = 0; index <= m_totNumOfSeats - 1; index++)
{
if (string.IsNullOrEmpty(m_nameList[index]))
strSeatInfoStrings[i++] =
m_nameList[index].ToString(); }
return strSeatInfoStrings.Length;
}