Need link or search terms to look up adding my classes to using statements

Rhodan

Active member
Joined
Apr 7, 2015
Messages
41
Programming Experience
10+
I've been googling but obviously I just don't know the right terms to use to get to step one in learning the subject.

What I want to do is make my classes show up as children of a root namespace the way Diagnostics appears as a child of System. I've been staring at a solution that does this but I'm just not making the connection.
 
Oh duh! After hours of fruitless searching I stumbled on the Oh Too Simple answer. After adding a reference to the project make the classes you want to appear PUBLIC and then it'll show up.

I was looking for something complexity that doesn't exist apparently.
 
What I want to do is make my classes show up as children of a root namespace the way Diagnostics appears as a child of System.

That doesn't actually make sense because Diagnostics is a namespace, not a type. System is a namespace and System.Diagnostics is a child of that. Classes like Stopwatch are declared as members of that child namespace. You simply declare the type inside a namespace block with the name you want, e.g.
namespace Parent.Child
{
    public class SomeType
    {
    }
}

You have now declared the Parent.Child.SomeType class.

Generally speaking, you create a folder in the Solution Explorer for each child namespace. For instance, if you create a project named Parent then a class added to the root level of the project will automatically be in the Parent namespace. If you then add a folder named Child to the project and add a class to that folder, it will automatically be in the Parent.Child namespace. When I say "automatically in a namespace" I mean that VS will add the namespace block with the appropriate name to the file by default.
 
Back
Top Bottom