'Why is visual studio code printing C# to terminal correctly, but not output?
I'm new to C#. I installed Visual Studio code along with the NET framework, and when I run my project in the terminal via 'dotnet run', everything works perfectly.
Yet, when I switch over to the output window I see this message --
Can anyone lead me in the right direction? I've been going at it for 10 hours now - research, reinstalls, and restarts galore - yet nothing seems to help. Again I stress: in the visual studio terminal, the code works fine.
What gives?
Edit: I manually added scriptcs to path, and now the error has change - "You cannot declare namespace in script code"
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
This is what happens without namespace; still no output.
Solution 1:[1]
Turns out, I had to get rid of everything aside from:
Console.WriteLine("Hello World!");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
I don't know why, but now 'run dotnet' in terminal doesn't work, yet the output does. Regardless, thanks to everyone who helpeD!!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jay |

