48 Replies
C# is project based; not file based.
$vscode
Follow the instructions here on getting started with DevKit for C# in VSCode: https://code.visualstudio.com/docs/csharp/get-started
Get started with C# and .NET in Visual Studio Code
Getting Started with C# and .NET Development in Visual Studio Code
If you are a beginner I'd recommend Visual Studio Community 2022
VSCode is a lot of manual work and configuration to make it work well
Yeah so it seems
I already installed the extensions and the dotnet thing
Yes, but you have not opened the folder containing the csproj / sln
Damn I need an account too
It's optional
Ohhh
Okay that's good
I was able to set everything up
Great!
Now I just need to copy my code here and see if it works now
You don't need Program and static void main when you have top-level statements, you also need to remove the namespace.
As they are generated underneath
Weird
Wdym by namespace
Its not weird
It is to me š
It requires 2 arguments
You only have one
Foo("hello", "bar");
What am I doing with the first one that Im not doing with the second one?
š
Wait
What is the argument here?
Yeah
Just saw that š
And check how have you declared the constructor
Is there a problem there?
read it
Read this code out loud for yourself
It expects a title and ..?
Oh yeah
I had already changed this I just got confused
š
I thought there was something else I was missing too
Correct.
As you had declared it to only accept 2 arguments of type string.
I get it now š
Thanks a lot
Anytime, note that you don't need to use class program and static void main, you can just call your code directly at the top of the file (under using declarations) via top-level statements.
I don't know what top level statements are š
Instead of
So all of this is useless and I can just get rid of it?
Yes. Except the code inside main, yes. as zzzz said
Not useless per se, the compiler just generates it for you
Okay I see
There's no harm to leaving it there though?
No
Just easier to use top-level statements, that's all.
Alright fair enough
I definitely have a lot to learn about c# š
I don't know anything
Anyway thanks guys
You taught me a lot in a short time
$close
If you have no further questions, please use /close to mark the forum thread as answered