I have endeavoured to start learning C# for real this time, I am thoroughly reading and going through Wrox.Professonal.C.Sharp.2008 and so far have learnt a lot, mainly about .NET after just reading the first chapter.
Currently on chapter #2 and have just learnt about variables (nothing new there) and am now onto scopes. I 100% understand what it's trying to tell me, however I have promised myself I will do all the code examples, actually type them out so I learn from typing it.
This current example is showing how you can have two variables with the same name (in this case "j") as long as they aren't declared in the same method (Or something like that). Anyways here is the code below:
Now I've copied that completely from the book, checked it line for line and it's correct but the code does not compile.Code:using System; namespace Wrox.ProCSharp.Basics { class ScopeTest { static int j = 20; Console.WriteLine(j); //Line 8!!! public static void Main() { int j = 30; Console.WriteLine(j); Console.WriteLine(ScopeTest.j); Console.ReadLine(); return; } } }
Line 8 has been bolded, I've looked at it and really cannot see what I'm doing wrong, ideas anyone?Error(8,20): error CS1519: Invalid Token '(' in class, struct, or interface member declaration
Error(8,22): error CS1519: Invalid Token ')' in class, struct, or interface member declaration