1145Views5Replies

Author Options:

Keep getting "invalid token" errors in C# Answered

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.

5 Replies

user
dungeon runner (author)lemonie2010-08-08

No dice - It doesn't work with C# :(.

Select as Best AnswerUndo Best Answer

user
lemonie (author)dungeon runner2010-08-08


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

L

Select as Best AnswerUndo Best Answer

user
dungeon runner (author)lemonie2010-08-08

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

Select as Best AnswerUndo Best Answer

user
lemonie (author)dungeon runner2010-08-09


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

L

Select as Best AnswerUndo Best Answer