Newbie to programing need help setting up c#
Hey, just started coding, ive worked with c++ briefly but already have forgotten everything lol. im trying rn c# mostly for school but i am pretty interested learning about .net structures
i wonder if i could get some help with it? everything just thows out errors even if its just a simple ''hello world'' print
41 Replies
it throws out a compiler error
What does the error say?
Gonna need more $details here.
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
What did you install? How did you create your project? How are you building it? How are you running it? What are you writing your code in?
[{
"resource": "/e:/ARTY/Coding/my firs5t prooaia/first.cs",
"owner": "_generated_diagnostic_collectionname#1",
"code": {
"value": "CS0260",
"target": {
"$mid": 1,
"path": "/query/roslyn.query",
"scheme": "https",
"authority": "msdn.microsoft.com",
"query": "appId=roslyn&k=k(CS0260)"
}
},
"severity": 8,
"message": "Missing partial modifier on declaration of type 'Program'; another partial declaration of this type exists",
"startLineNumber": 3,
"startColumn": 7,
"endLineNumber": 3,
"endColumn": 14
}]
and as a test im just usimg this:
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
i was folowing a guide on youtube, i downloaded a .net sdk, got the c# dev kit and extension
on vs code
You have more code than that
its complaining that you have declared the
Program
class twice, once with partial
show a screenshot of your project directory?whats that?
we highly recommend NOT using vs code as a beginner
the folder where your code is
guh my course requires it
you have two
.cs
files
okay thats fine thenwhat do i do now?
you have TWO files with code in it
you only posted the content of one
open both and compare
its just this on the second one
ah see
delete your
first.cs
okay
that
Program.cs
you have is the default main entry point
it contains wahts called "top level statements" code, which actually is the content of a main method on a program class
thats why you are getting your "weird" error, because you used Program
as your class name and thats a bit specialohh
i think i get it
getting more errors
lmao
I can't read your mind or see your screen, y'know
true true, wanna maybe call if you are free ?
not free
post your errors here
so you didn't remove the file?
oh i have to like compleatly delete it?
thats what I said no?
okay yee
no errors but i get no output
dotnet run
in the terminalis it posible to get it on a seperate screen?
like the output
sure, open an external terminal on your other screen
and run
dotnet run
from thhereyou gotta be in the right folder lol
how do i do that?
cd
just google "how to use the terminal in windows" or somethingalright
this is a very important core skill for advanced computer usage
Even though the course "requires", I'd still do my best to use Visual Studio Community instead. You'll save yourself from so many headaches...
Agreed
alright!