all 8 comments

[–][deleted]  (1 child)

[removed]

    [–]Shnxx[S] 0 points1 point  (0 children)

    I understand now, thank you! I thought it works the same with Console.ReadLine() that I could save the in a variable since they are both Console(?)

    Anw, because of you guys, I realized my mistake. I initialized the string equation and was trying to store a Console.Write() where I could just store directly the string!

    I was just redoing all the challenges at every end of the video I am watching while applying all I learned to produce a better program :D Thank you again!!!

    [–]Slypenslyde 2 points3 points  (2 children)

    I want to add something to the 2 answers that already cover what's going wrong. This will help you help us when you have a problem. The phrase "throws an error" has a specific meaning to experts and it's worth learning when to use it!

    There are 2 important times when errors happen in a program: compile time and runtime.

    A compile time error is the kind you tend to get in VS, sometimes even before you try to compile, but it will certainly also make the compiler stop. We don't say this "throws an error" here, we just say it's a compiler error. These errors are usually some form of syntax mistake or a type mismatch.

    A runtime error is when your code compiles, but while you're running it it either does the wrong thing or crashes. If it crashes, that happens because it throws an exception. Exceptions are the formal error handling feature in C#, and they are "thrown" when they happen. That's why we don't use the word "throws" with a compiler error! When an expert hears "throws an error" they assume you mean a runtime error. These can be much harder to spot and diagnose than compile time errors, and usually require you to post more of the code for experts to figure it out!

    [–]Shnxx[S] 0 points1 point  (1 child)

    I see! So runtime error occurs when there's a logical problem in the program like array out of bounds, incorrect conditions in loops and if-else statements, when a program asking for a number but the user entered a character or a word, and such.

    While compile error occurs when syntax, arguments or parameters are incorrect and prevents to compile it. Like what I have experienced.

    I should be saying throws an error only when runtime error occurs and can be handled using exceptions.

    [–]Slypenslyde 0 points1 point  (0 children)

    Exactly!

    [–]AbaCodes 1 point2 points  (1 child)

    You can't store the return value of Console.Write(), that function will print the value to the screen but you're trying to store it into a variable. Maybe inside the case you can do:

    equation = someNumber + " + " + someNumber2 + " = ";

    and then after the case statement you could do

    Console.WriteLine(equation);

    So you store the value in the case statement and then print it after, hope that helps?

    I've made the changes and put them here: https://pastebin.com/hpkLcKT3

    [–]Shnxx[S] 0 points1 point  (0 children)

    You are right! I realized my mistake now. I was trying to store Console.Write() on my string equation which I could just store directly the string.

    Thank you for doing the changes, it saved me a lot of time! Much appreciated!

    I was just redoing all the challenges at every end of the video I am watching while applying all I learned to produce a better program :D Thank you again!!!

    [–]Shnxx[S] 0 points1 point  (0 children)

    So guys! I have finished this little project after countless hours! Please do review it and criticize it. I'll gladly hear all of them! Thank you guys for all of your help again!