C
C#5mo ago
Ducki

✅ using System; is greyed out, any help?

No description
12 Replies
Ducki
DuckiOP5mo ago
using System;

namespace Test_1
{

class Program
{
static void Main(string[] args)
{

Console.Title = "First Ever Test";
Console.ForegroundColor = ConsoleColor.Green;

}
}
}
using System;

namespace Test_1
{

class Program
{
static void Main(string[] args)
{

Console.Title = "First Ever Test";
Console.ForegroundColor = ConsoleColor.Green;

}
}
}
Jimmacle
Jimmacle5mo ago
that's not an error as long as you don't get any errors trying to actually use types in your code your usings are fine, you potentially have global usings defined in the project making the one in this file redundant
Ducki
DuckiOP5mo ago
nothing happens when i run the code which is the issue
Jimmacle
Jimmacle5mo ago
well, your program sets the title and the foreground color then immediately exits so 1) you have to be running this in an actual console window and not VS/Code's terminal to see any of that code do something and 2) you probably want to add a pause so the window doesn't close immediately when you run it
Ducki
DuckiOP5mo ago
how would i run it in a console window? sorry for the basic questions, python was quite a lot simpler.
Jimmacle
Jimmacle5mo ago
either double click the exe produced by dotnet build or open cmd/powershell, go to the project directory, and dotnet run it would probably help to print some actual text to the console so there's more to see
Ducki
DuckiOP5mo ago
yep ive added that, just figuring out the dotnet build rn
The Fog from Human Resources
Additionally you can click run if you use Visual Studio :kadse:
Jimmacle
Jimmacle5mo ago
it will put an exe in bin/Debug/net8.0/ iirc
Ducki
DuckiOP5mo ago
following this youtube guide its supposed to open up a cmd window to display my "Hello World" text, which it doesnt quite do and instead sends it to the terminal in vsc, any way i can change this?
Jimmacle
Jimmacle5mo ago
yeah, don't run it through vsc or find a relevant setting in the C# extension to make it use a standalone console window i'm going to guess the tutorial you're following is using VS which would show a standalone window by default (and is generally a better option for C# than VSC)
Ducki
DuckiOP5mo ago
ahhh that would make a lot of sense, yes, ill be downloading VS, thank you for all your help 😄 +rep to you mr jimmacle
Want results from more Discord servers?
Add your server