Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input String Correct Format

Status
Not open for further replies.

hisheeraz

Programmer
Mar 24, 2003
28
0
0
AU
Hello Everybody
When i am compiling the code below then i am getting this error

[red]Input String is not in the correct format[/red]

what could be the problem there in the code below...

Code:
static void Main(string[] args)
        {
            string Signal = "0"; // giving the string a netural value
            while (Signal != "X")
            {
                Console.WriteLine("Enter some Signal: ");
                Signal = Console.ReadLine();
                
                Console.WriteLine("Signal entered was: {0}\n", Signal);

                if (Signal == "A")
                {
                    Console.WriteLine("Fault Found - Aborting...");
                    break;
                }
                if (Signal == "0")
                {
                    // all is fine just continue working
                    Console.WriteLine("All is fine - Move On");
                    continue;
                }

                if (Signal != "A" || Signal != "0")
                {
                    // all problem...raise alarm
                    Console.WriteLine("{0)---------Invalid entry!\n", Signal);
                    continue;
                }
                
            }
        }

thanks

§ Rented Lips §
----------------
Begning To Learn
----------------
 
Console.WriteLine("{0)---------Invalid entry!\n", Signal);
should be...
Console.WriteLine("{0}---------Invalid entry!\n", Signal);

It's missing a }...

Sharing the best from my side...

--Prashant--
 
that was tricky

thanks prashant

§ Rented Lips §
----------------
Begning To Learn
----------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top