I'm new to c#, but I'm trying to create a basic program that can use a function that adds to numbers (this is just practice I know it's inefficient.
{
int AddNumbers(int num1, int num2) //Here's where the error comes
{
int result = num1 + num2;
return result;
}
int num1 = 10;
int num2 = 20;
AddNumbers(num1, num2);
However, when I try it, it says that "A local parameter named 'num1' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter". I assume that this is because I declared the variables while calling the function, but I don't know how to fix it.
Thanks for any help!
EDIT: Just to be clear, the numbers after the functions are the number I would like to be added in the function