✅ Main() bug with 2 files
so basically, i this this folder, and it has a lot of different cs files each one individual from the last, and i'm noticing that once i have a Main() method in one file, i can't make one in the other, i get an error, how do i fix this?
50 Replies
you dont
you cant have more than one main method
how would that work
no
uhh
it's 2 different files
one file has a main method
another file has one
it's 2 seperate projects
yeah how would that work
wdym?
oh
i only see one project file tho
and you cant nest projects
afaik at least
it's the "hex-code-checkers"
wdym?
it works if they're in the same folder
where is the other project file
.
thats a code file
project files end in .csproj
no
i mean
you cant have multiple entrance points in one project
it's a different project, not a different project file
oh
so i have to make a different csproj for every file?
because how would it pick which one to run
pick the file
and f5
different project means different csproj
c# doesnt run files
that's weird
its project based
because it works
on a different folder
all the files in a project get compiled to a single assembly
which you run
ok
hold on
this works
it would work if you moved the file to a directory higher than the project file, because then its not part of the project
each one has a different Main file
each one of what
no, that's not what i mean
each .cs file
each one has a main method?
huh
it worked yesterday
that's weird
well
so it has to be a different folder for each file?
that's very annoying
no
oh?
you just cant have more than one main method
doesnt matter where the file is
or what the name of the class or struct is
you just cant define multiple entry points
for 1 project?
for 1 .csproj file?
for one project yeah
ah
got it
aka csproj
how do i connect a csproj to a .cs file
?
you put the cs file in the same folder as the project file or in a folder under it
got it
so would this work?
hold on
would what work
so imagine
there is a folder called c#
and inside there are 2 folders
in each there is a .csproj
and a seperate .cs file in each
would that work?
yes because those are 2 seperate projects
ok
thanks
typically we have a solution file that kind of groups the projects
so you can build the solution and it builds all the projects
or run tests on the "solution" and it would run all the test projects in it
how do i do that?
dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
basically
ok, i think i'm gonna have to restructure a few gits
will list the projects
tysm!!!
i'm finally diving into the deeper end of C#
so i'm learning these things for the first time
thank you
shoould i /close?
yup learning is cool
np
$close
Use the
/close
command to mark a forum thread as answered