|
-
May 12th, 2004, 12:19 AM
#1
Thread Starter
Lively Member
object reference is required for the nonstatic
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
{
}
}
}
===============
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|