Computing.Net > Forums > Programming > I have a problem with Visual C#...

I have a problem with Visual C#...

Reply to Message Icon

Original Message
Name: El-Trucha
Date: August 31, 2004 at 14:21:39 Pacific
Subject: I have a problem with Visual C#...
OS: Windows 2000
CPU/Ram: 1.4 GHz/128 MB
Comment:

Hello!!
OK...I got a problem here with my Visual C# .NET mail course...
I'm trying to make a program, and my book tells me exactly how to do it...and it compiles, but it doesn't run!! :(
When I run the program's EXE, it asks me what debugger I wanna use...I tried with all 3 debugging options but for some reason none worked...:(
Finally I decided to go to the program, type in the code, compile it, and then debug it...it finds this error during debug:
-----
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: Input string was not in a correct format.
-----
Why is it in an incorrect format and it compiled anyway??
After that message, I click on "Break" to corect the error, and it highlights the following line:
-----
Console.WriteLine("The difference between {0} and {1} is {2}", value1, value2, diff);
-----
What's wrong with that?!! also, when I commented out/deleted that line, then it highlights the next line, which has the same fonction!!
This is the full code:
-----
using System;
public class DemoVariables2
{
public static void Main()
{
int value1 = 43, value2 = 10, sum, diff, product, quotient, remainder;
product = value1 * value2;
quotient = value1 / value2;
remainder = value1 % value2;
sum = value1 + value2;
diff = value1 - value2;
Console.WriteLine("The sum of {o} and {1} is {2}", value1, value2, sum);
Console.WriteLine("The difference between {0} and {1} is {2}", value1, value2, diff);
Console.WriteLine("The product of {0} and {1} is {2}", value1, value2, product);
Console.WriteLine("{0} divided by {1} is {2}", value1, value2, quotient);
Console.WriteLine("and the remainder is {0}", remainder);
}
}
-----
What is wrong with it?!! plz help!!
Thanx!! ;)

PS: I'm running the program on a Virtual PC 2004 virtual machine...the host OS is WinXP Home, which is not fully supported by Visual Studio...:( maybe that's the cause??

El-Trucha


Report Offensive Message For Removal


Response Number 1
Name: Guy
Date: August 31, 2004 at 19:23:21 Pacific
Reply: (edit)

Look closely at the characters you have between the curly braces.

Regards, Guy


Report Offensive Follow Up For Removal

Response Number 2
Name: El-Trucha
Date: August 31, 2004 at 20:07:14 Pacific
Reply: (edit)

I read ur post and I almost died...
How can I b so stupid?!! :@
I read and checked it 01010001 (81 in Binary...) times and I couldnt find the error!!
But anyways...much thanx!! ;) I can keep studying now!! ;);)

El-Trucha


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: I have a problem with Visual C#...

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge