I guess you are pretty new to development :)
there are a few ways to achieve what you want, the simplest (but not necessarily the best, depending what you are doing) is:
public void Accept()
{
Console.WriteLine("Enter the first digit");
int a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the second digit");
int b=Convert.ToInt32(Console.ReadLine());
int answer = Calculate(a, b);
}
int Calculate(int firstValue, int secondValue)
{
return firstValue + secondValue;
}
You can of course just add a and b in the
Accept
method, but I assume you don't want to do this. If you are doing a lot of this sort of stuff, you should create something like a
Calculator
class, the exact implementation depends on what you need to do. I strongly suggest you google for "C# Properties" and "Object Orientation". Object Orientation is really worth learning as you learn the language, otherwise you will end up fighting the language rather than working with it.