Link to home
Start Free TrialLog in
Avatar of Kokas79
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("lowercase:\t{0}",s.ToLowerCase);
            }
            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
Avatar of NipNFriar_Tuck
NipNFriar_Tuck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial