Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial1 Answer
andren
28,558 PointsThere are a couple of errors.
The first issue is that you don't actually have any class in your program, you define a namespace and then just define a Main method, the Main method cannot exist in a vacuum. It needs to be within a class.
The second error is In this line:
Num2 = Convert.ToInt32(Console.Readline());
You misspell the ReadLine
function as Readline
.
The third error is that in C# Strings by default don't span multiple lines, so having a line break within them like you have is invalid. There are two ways around that, one is to turn them in to a verbatim string literal
which is done simply by placing the @
symbol in front of the starting qoute mark of the string like this:
@"The result of subtraction is :
{0}", result);
That allows strings to span multiple lines but it also has other side effect, like the fact that it will ignore ignore a lot of special symbols like \n
and other things that usually has a special meaning in a string.
But the recommended way of creating a line break in a string is not to use verbatim string literals
but simply placing a new line symbol in the string. Like this:
"The result of subtraction is :\n{0}", result);
The \n
symbol creates a new line, so even though the string looks like it only spans one line when it is printed out there will be a line break where the \n
character is placed.
Also you have forgotten to end the break statement in the case 4
section with a ;
(semicolon)
Those are the only errors that will cause a crash, but there is another issue, which is the fact that you print out Enter an operation
between asking for the first and second issue before you have presented the operations and without actually registering an input from that prompt. You then ask for the operation again later down in your program. You therefore need to redesign this part of your program a bit. You have also not implemented any looping which you need to do if you wish to actually satisfy the last comment you have written in your application.
Peter Gess
16,553 PointsPeter Gess
16,553 PointsWow, that was rough. Thanks a lot for the help.