in vs code you need to open the folder that contains the project. you also need to install c# dev kit extension. before selecting the debug pane, you select the program.cs file, so the debugger knows what to debug.
a compile happens before debug. if the compile fails, you must fix the compile. you can open terminal, check that your in project folder. then type
% dotnet build
to get build errors.
to check you installed dotnet correctly try:
% ## check dotnet sdks installed
% dotnet --list-sdks
% ## create a folder and switch to it
% mkdir testapp
% cd testapp
% ## create test app, build and run
% dotnet new console
% dotnet build
% dotnet run
% ## open in vs code
% code .
if this also works, try with visual studio code.