Thread: custom namespaces

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    18

    custom namespaces

    Hey, I am relatively new to C#, and realize that with the advent of namespaces, .h files and the like are no longer needed. But how can I code in multiple files? (is this even in the framework).

    Since everything is now in classes, I dont like having 1 huge file with miles and miles of code in it. So I am writing most of my classes in a namespace in a seperate file, then would like to have import them into my file containing "main." How do i do this? I figure if i just typed

    using MyNamespace;

    that VS.Net would not know where to find it, so I guess where do I go after I have coded my own namespace?

    Also, if anyone can point me in the right direction of how to go about using multiple threads of execution inside c#, i would appreciate it. I have previously only done execution with a single thread, but my current project needs multiple threads to accomodate different sensors and waiting devices, and I don't even know where to begin with it. Thanks

    jbj
    cow

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    For threading, look into System.Threading, the class would be System.Threading.Thread. There should be a lot of tutorials out there, it's a bit much to explain in one or two sentences.

    You can have multiple source files in one project. Those sources do not need to be included like in C++ to be known. Every source file knows every other source file while compiling.

    Say you write a class in file a that is called ClassA in namespace NamespaceA. To use it in file B, all you have to do is either #using NamespaceA and instanciate a ClassA or using the full path and instantiating NamespaceA.ClassA.

    In Visual Studio.NET this is automatic, if you use csc the commandline compiler, look into it's options how to compile multiple source files. I think a good measure is one file per class.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    18
    so just as long as I add the file to the project, it is good to go?

    Kinda forgot about adding files to the project/solution, so that may have been my missing link. Once it is in the project, it is good to go.

    Will mess around with threading? Is it hard to learn/grasp? Is it that much of a stretch from normal single-execution programming?

    jbj
    cow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom Allocation
    By SevenThunders in forum C Programming
    Replies: 17
    Last Post: 04-09-2007, 04:10 PM
  2. Stl sets and custom classes.
    By cunnus88 in forum C++ Programming
    Replies: 3
    Last Post: 05-12-2006, 11:58 PM
  3. Custom Draw TreeView
    By eXistenZ in forum Windows Programming
    Replies: 3
    Last Post: 08-05-2005, 12:34 PM
  4. Clipboard and Custom Types
    By McClamm in forum C# Programming
    Replies: 1
    Last Post: 09-16-2004, 04:43 PM
  5. anybody here uses custom namespaces
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 03-19-2002, 05:43 PM