C
C#2w ago
Ducki

✅ using System; is greyed out, any help?

No description
12 Replies
Ducki
Ducki2w 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
Jimmacle2w 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
Ducki2w ago
nothing happens when i run the code which is the issue
Jimmacle
Jimmacle2w 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
Ducki2w ago
how would i run it in a console window? sorry for the basic questions, python was quite a lot simpler.
Jimmacle
Jimmacle2w 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
Ducki2w ago
yep ive added that, just figuring out the dotnet build rn
Somgör from Human Resources
Additionally you can click run if you use Visual Studio :kadse:
Jimmacle
Jimmacle2w ago
it will put an exe in bin/Debug/net8.0/ iirc
Ducki
Ducki2w 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
Jimmacle2w 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
Ducki2w 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