Instructables

Keep getting "invalid token" errors in C#

I've spent the last few days trying to learn the C# language, but Visual C# 2008 keeps saying "invalid token" when my syntax is perfectly fine. Here is my source code:

Console.WriteLine("Initializing...");
            string path = "startup";
            private Hashtable text = new Hashtable();
            text.Add("startup", "Please type a command. For a list of available commands, type <help>.");
            Console.WriteLine("Start up complete.");
            while (true)
            {
                string info = text[path].ToString();
                Console.WriteLine(info);
                string comm = Console.ReadLine();
                if (comm == "help")
                {
                    Console.Writeline("...");
                }
            }

The main thing it keeps rejecting are the parentheses. I've even tried removing them, to no avail. I would vastly appreciate some help.

lemonie3 years ago

i wonder if this will be of any use?
http://www.chamisplace.com/colorizer/cc.asp

L
dungeon runner (author)  lemonie3 years ago
No dice - It doesn't work with C# :(.

oh dear. i couldn't see a fault with your code

L
dungeon runner (author)  lemonie3 years ago
The numerous problems with the Hash table were fixed when I added "using System.Collections" to the top. Everything else just fixed itself. Sigh, Visual Studio is a fickle beast indeed.

-Y

well we've learned something then, thanks for the update.

L