using System;
class program
{
static void Main(string[] args)
{
public int find( int n, int p)
{
if(n==0) return p;
else return find(p%n,n);
}
Console.WriteLine( find(12,8));
}
}
Why the above code is giving errors?
I am new to C# programming.
Printable View
using System;
class program
{
static void Main(string[] args)
{
public int find( int n, int p)
{
if(n==0) return p;
else return find(p%n,n);
}
Console.WriteLine( find(12,8));
}
}
Why the above code is giving errors?
I am new to C# programming.
Posting exact text of the exception message, maybe including the stack, is very helpful.
it doesn't matter what errors he has in this case. he's defined his find function inside the main function.
but yes, error messages are always helpful!
As already mentioned C# does not support nested functions. (at least not without the use of delegates and anonymous functions)
Define the "find" method outside the main method, and make it static so that the static main method will be able to find it.