Kokas79
asked on
Object reference not found in Main()
Hello
When i try to build this
class Class1
{
static void Main(string[] args)
{
Console.WriteLine("default :\t{0}",s) ;
Console.WriteLine("lowerca se:\t{0}", s.ToLowerC ase);
}
string s = "C# Programming for me";
}
I get this error "An object reference is required for the nonstatic field, method, or property 'PigLatin.Class1.s' "
Is this because Main is a static method and cannot operate with nonstatic fields? I thought that s that i use in the WriteLine statement is the actual reference to the string object i declared at class level. So why cant it find it?
When i try to build this
class Class1
{
static void Main(string[] args)
{
Console.WriteLine("default
Console.WriteLine("lowerca
}
string s = "C# Programming for me";
}
I get this error "An object reference is required for the nonstatic field, method, or property 'PigLatin.Class1.s' "
Is this because Main is a static method and cannot operate with nonstatic fields? I thought that s that i use in the WriteLine statement is the actual reference to the string object i declared at class level. So why cant it find it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.