CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Location
    Canada, Saskatchewan province
    Posts
    29

    [RESOLVED]How to use someone elses classes in visual studio?

    Hi, I'm using visual studio 2008 and I recently downloaded a class example from a third party website. The example contains one directory and inside this directory are about 5 classes. This directory also contains a few other subdirectories that also contain .cs files.

    I fired up a new project in visual studio 2008 and I dragged the folder into my project and all the directories and files show up fine now in solution explorer.

    My question is that after looking at some of the files, I notice they are all using this namespace

    namespace JeremyB.custom
    {
    ...
    }


    So how do I go about loading up and instantiating some of these classes so I can work with the objects? I know how to do this normally when the classes are all in one file.

    Object myIdentifier = new Object();

    or if you want to use overloads you can check the calss definition files to see if there are any other ways to fire it up.

    Do I need to add a using statement to my Program.cs in order to use these?

    I tried typing JeremyB.custom. but intellisense is no help so I must be missing a using directive?


    any help much appreciated,

    Ricky,
    Last edited by RickyWh; December 19th, 2008 at 05:17 PM.

  2. #2
    Join Date
    Dec 2008
    Location
    Canada, Saskatchewan province
    Posts
    29

    Re: How to use someone elses classes in visual studio?

    I must have been doing something wrong the first it seems intellisense is now working fine. However If I didn't want to continually type the namespace what would my using directive look like?

    Ricky,

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: How to use someone elses classes in visual studio?

    Either type the fully qualified name: JeremyB.custom.ClassName or make use of the using statement "using JeremyB.custom;"

    btw: This is NO different than how you access collections (which are in a namespace), windows form controls (which are in a different namespace), Data (which is in yet another namespace)......
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Dec 2008
    Location
    Canada, Saskatchewan province
    Posts
    29

    Re: How to use someone elses classes in visual studio?

    Sweet, thanks for help.

    using JeremyB.custom;

    Works like a charm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured