anis_b
May 12th, 2004, 12:19 AM
I get this error when i call jam() inside Main()
"An object reference is required for the nonstatic field, method, or property"
It goes away if I add the "static" keyword before the jam definition, i.e. "static void jam()" instead of "void jam"
May I know the reason why so ?
==========
using System;
namespace WindowsApplication3
{
public class Class6
{
static void Main()
{
jam();
}
void jam() // this doesnt work
//static void jam() // this works
{
}
}
}
===============
"An object reference is required for the nonstatic field, method, or property"
It goes away if I add the "static" keyword before the jam definition, i.e. "static void jam()" instead of "void jam"
May I know the reason why so ?
==========
using System;
namespace WindowsApplication3
{
public class Class6
{
static void Main()
{
jam();
}
void jam() // this doesnt work
//static void jam() // this works
{
}
}
}
===============