C
C#2y ago
wcasa

❔ how is c# project compiled??

Hello everyone, how is c# project compiled when it has several files, like 2 c# console applications?
14 Replies
nukleer bomb
nukleer bomb2y ago
One project can have multiply files in it... But two console applications should be two different projects When compiling project, Roslyn (C# compiler) just compiles all .cs files in this project
wcasa
wcasaOP2y ago
at the same time? sooo, it just takes everything, connects into 1 .cs file, runs, which means that I am not running file -> but instead running project??
JochCool
JochCool2y ago
Yes, that's correct
wcasa
wcasaOP2y ago
in order to access that other class, it has to be public?
JochCool
JochCool2y ago
All classes in your project will be compiled; public is only about where in the code you can use the class
wcasa
wcasaOP2y ago
by the way what is it called when several c# projects are connected? like here
JochCool
JochCool2y ago
In the screenshot you show only one c# project?
wcasa
wcasaOP2y ago
yes
JochCool
JochCool2y ago
What do you mean with several c# projects connected
wcasa
wcasaOP2y ago
2 C# files under 1 project so that i could use classes/methods from other class in the main class
canton7
canton72y ago
That's just a normal project? It's very rare to only have a single file in a project
Angius
Angius2y ago
C# projects can have thousands of files in them You can use code from other files just like that Nothing special needs to be done
333fred
333fred2y ago
I think you may have a bit of a misconception on what the word project means in C#. Unlike in, say, js or python, a single C# file is not a project. A project is the csproj file, and all of the cs files it says to include (all the cs files in the current directory and nested directories, by default) When compiled, the cs files aren't combined into a single cs file and run. They are compiled to a lower-level language, cil (commom instruction language) and the instructions are put into a dll. Then that dll is run When the dotnet runtime runs that dll, it takes the cil and jits (just-in-time compile) it to native machine code. No interpretation of your code happens, as in js or python
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server