in this method
if im returning in the loop, why does the method require another return?
what should the last return be? i dont really understand this.
C#:
public static string GetLimitedString(string prompt, int min, int max)
{
string userString;
bool hasAString = false;
do
{
Console.WriteLine(prompt);
userString = Console.ReadLine();
if (userString.Length >= min && userString.Length <= max)
{
return userString;
hasAString = true;
}
} while (!hasAString);
return userString;
}
if im returning in the loop, why does the method require another return?
what should the last return be? i dont really understand this.
Last edited by a moderator: