Visual Studio .NET - implementing command console

Asked By Anjali agarwal on 07-Sep-11 03:42 PM
Hi All,

I need to implement a command console for changing settings on a particular object.  The command console should allow you to enter a string and will return the response (very similar to a terminal session).  The commands are as follows:
SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”.  If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message.

any help will be appreciated.
Mikael Gonella replied to Anjali agarwal on 07-Sep-11 04:35 PM
Static main.... bla bla

string s = Console.ReadLine(); This is were you read what the user has inputed

You could create yourself a class such as Command.vb or cs with approriate functions and then a collection of commands.
Then you could loop in to this collection to see if the command is accepted by the system

if there is only one single command than do it this way

string s = console.ReadLine();
//trim your string here, check if the property exist
try{ = substring;  // if the type is not correct, it will throw an exception
catch(exception e)
Console.WriteLine("Property does not exist");

hope it helps
Anjali agarwal replied to Mikael Gonella on 08-Sep-11 11:58 PM
Thanks Mikael!!