C
C#2d ago
Faker

✅ What is a "solution" in C#? How does it differ from a "project" ?

A solution in C# is just our project root folder where we can send organised code in that particular folder?
11 Replies
Angius
Angius2d ago
Solution groups multiple projects together
ero
ero2d ago
Defines some build configurations
Angius
Angius2d ago
The usual structure is something like
MyCoolProject
|— MyCoolProject
| |— MyCoolProject.csproj
| \— Program.cs
|— MyCoolProject.Tests
| |— MyCoolProject.Tests.csproj
| \— ...
|— MyCoolProject.Shared
| |— MyCoolProject.Shared.csproj
| \— ...
|— MyCoolProject.sln
|— Readme.md
\— ...
MyCoolProject
|— MyCoolProject
| |— MyCoolProject.csproj
| \— Program.cs
|— MyCoolProject.Tests
| |— MyCoolProject.Tests.csproj
| \— ...
|— MyCoolProject.Shared
| |— MyCoolProject.Shared.csproj
| \— ...
|— MyCoolProject.sln
|— Readme.md
\— ...
Faker
FakerOP2d ago
oh ok, why is it important ? I mean why not used only the project names like MyCoolProject or MyCollProject.Tests
Thinker
Thinker2d ago
There are a lot of times when you might want to group multiple projects into the same overall project. For instance, if you're writing a calculator, you might want one project which contains all your logic and classes, one project which is a console application which uses the logic and classes, and one project which contains unit tests for your logic.
Faker
FakerOP2d ago
yep I see thanks !
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
Faker
FakerOP2d ago
I tried to visualize what you mean, like for a game, we can have a UI or console app? But why would we want to have all the code in the same IDE and have their own set of dependency and same debug experience pls... I'm still new to programming, so I didn't build big projects yet :c
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
Angius
Angius2d ago
Since you gave the example of a game... You can have Game project, Game.Server project, and Game.Shared project all in the same solution Both the game and the server, for example, need to know what PlayerStats are That can go into Shared And be used by both the game and the server projects Without a solution, you would have to reference that Shared project with its path, or you'd have to package it and install as a nuget package, or what have you But since all three are in a solution, it's easy to reference one project from another Because they share the same root
MODiX
MODiX2d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?