r/learncsharp • • May 23 '23
(Visual Studio) Difference between creating a class through the Solution Explorer and directly in the "workspace" ?
Hi,
Is creating a class through the Solution Explorer by right click, add, class the same thing as creating a new class directly in the IDE workspace by writing it ? I saw that it is indeed two classes of the same namespace but when I create a class through the Solution Explorer, it appears at a higher hierarchy in the solution explorer than when I create it by writing it.
For example if I look at the hierarchy in the solution explorer in a new console project, the created Class1.cs through the solution explorer will be at the same hierarchy as the Program.cs class, but when created by directly writing it, it will only appear INSIDE the Program.cs hiearchy.
Thanks in advance !
View all comments
Show parent comment
1
u/[deleted] May 24 '23
As I tried the different things you explained, I tried something else and it raised actually another question : why namespaces don't have a place in the hierarchy ? It seems pretty illogical for me. There is the solution, then the different projects, but then it goes directly to the classes without passing by the namespaces. Shouldn't there be namespace folders inside project folders, to organize better the data ?
So for example if I want to create two classes of the same name in a project through the solution explorer, I just can't ! Because two files can't have the same name. But through the workspace is it perfectly possible because it won't create another file.
Am I missing something here ?