I was aiming to create a simple code that takes an input and gives out the square of the number. I used another method for calculation but i think there is an error with the method setting. Please take a look.
using System;
namespace NumberM {
class InputLocation {
public static void Main (string [] args) {
int PlsCall;
begin:
Console.Write ("Please specify a number : ");
string NumInput = Console.ReadLine ();
int NumNewValue = Int32.Parse (NumInput);
Console.WriteLine("Is {0} the number you specified?", NumNewValue);
string Ans = Console.ReadLine();
if (Ans == "yes" || Ans == "Yes") {
Console.WriteLine ("That means {0} is your number. All right. Calculating.");
// disable once SuggestUseVarKeywordEvident
CalcNumb InP = new CalcNumb();
PlsCall = InP.Calculation (NumNewValue);
} else {
Console.WriteLine ("That might be an issue. Taking back.");
goto begin;
}
}
}
class CalcNumb {
public int Calculation (int number) {
int Store = number * number;
Console.WriteLine ("This is the square of your number : {0}" , Store);
}
}
}
I get an error at the line 35 and 26 for calling method. PlsCall = InP.Calculation (NumNewValue); public int Calculation (int number) {
I get something like this. I can't translate well, but it is Turkish, if you need the translation.
'NumberM.CalcNumb.Calculation(int)': tüm kod yolları değer döndürmez (CS0161)
Thanks in advance for the help.
The calculation method is an integer and you are not returning anything