Reputation: 19
The name of the function is where the error is produced. It states that 'not all code paths return a value'. Why am I getting this error and how do I correct it?
public List<List<String>> getAvailablePMs()
{
public List<List<String>> allAvailablePMs = new List<List<String>>;
for (int s = 0; s < MyStaticValues.PMmanagerArray.Count; s++)
{ //for each PM in PMmanagerArray (excluding faulty or in-use)
if (MyStaticValues.PMmanagerArray[s][1] == ""
&& MyStaticValues.PMmanagerArray[s][2].Equals(0)
&& MyStaticValues.PMmanagerArray[s][3].Equals(0))
{//if the PM assigned bay is NULL AND PM status is not in use AND not faulty
allAvailablePMs.push(MyStaticValues.PMmanagerArray[s][0]);
}
}
return allAvailablePMs;
}
Upvotes: 0
Views: 62
Reputation: 8553
You must not use public
inside a method, this is giving a compile error that is confusing the compiler, making it complain about "not all code paths returning a value".
Also, there are other erros on your code, there is no push
method in List
, you should use Add
. Also, if MyStaticValues.PMmanagerArray[s][0]
is a string
, you can't add it to allAvailablePMs
, since it expects a List<string>
.
On a style note, it is a convention that all methods and properties in C# are PascalCase, not camelCase, so your method name should be GetAvailablePMs
.
Upvotes: 1