How can I solve this problem? (the text at the end "brah I've told...). The program want's that I give an int back, but I want to give a string back. How can I solve this problem? Because I've told it that it will be an int returned, but I want to have this failure message. Thank you very much guys!!
edit the problem exactly is, that the program won't compile because of
else return Console.WriteLine("brah I've told ya that I want more than 5");
Because my program wants a int, no string.
static void Main(string[] args)
{
Console.WriteLine("Give me a number over 5 bro");
int x = int.Parse(Console.ReadLine());
int result = AddNumbers(x, 5);
Console.WriteLine(result);
Console.WriteLine("Press enter to close...");
Console.ReadLine();
}
public static int AddNumbers(int number1, int number2)
{
int result = number1 + number2;
if (result > 10)
{
return result;
}
else return Console.WriteLine("brah I've told ya that I want more than 5");
}
}
}