Problem in Lesson 4 of Infamouse C# Tut

01/12/2011 17:20 elmo3zeb#1
When i always Test what he says in Lesson for like this


Code:
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            double debt = double.Parse(input);
            debt = debt * 1.5;
            Console.WriteLine(debt);
        }
Or

This


Code:
        static void Main(string[] args)
        {
            double balance = double.Parse(Console.ReadLine());
            balance = balance + (balance * 0.07);
            Console.WriteLine(balance); // first month
            balance = balance + 250.00;
            balance = balance + (balance * 0.07);
            Console.WriteLine(balance); // second month
        }

I Get Warning Message


Does this Tut like other tutorials in all sites?
Or that Tut for Coding Conquer stuff only?
If it's like the other tutorials other sites then i have one for my language
01/12/2011 17:58 _Emme_#2
Please tell us what warning message you're getting. If your console is just closing, it's caused by you're not waiting for an user input (this is if you're running with debugging enabled (try Ctrl+F5 instead of just F5).
01/12/2011 18:19 Korvacs#3
The warning is probably about:

foo = foo + bar;

Which of course can be optimized to:

foo += bar;

And similar.
01/12/2011 19:07 elmo3zeb#4
This is the Image of testing it

[Only registered and activated users can see links. Click Here To Register...]
01/12/2011 19:29 Ian*#5
static void Main(string[] args)
{
string input = Console.ReadLine();
double debt;
bool debtParsed = double.TryParse(input, out debt);
if (debtParsed)
{
debt = debt * 1.5;
Console.WriteLine(debt);
}
else
Console.WriteLine("Failed to parse value.");
Console.ReadKey();
}
It's because you didn't input a value, using TryParse will check to see if it can or cannot parse the value.
01/12/2011 21:46 _Emme_#6
Just so you know, if you ever run into an error later on and want to troubleshoot it at any forum, what you need to include is the error message and the code where it occurs in, in this case your message is "Input string was not in a correct format", and the row where it is yellow.