Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. can we use two diffrent namespaces

can we use two diffrent namespaces

Scheduled Pinned Locked Moved C#
csharptutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nagarajuepuri
    wrote on last edited by
    #1

    hi, can we use two diffrent namespaces one after another within a single C# programs, for example something like following code.. Using system1; //namespace1 Using system2; //namespace2 namespace custom_namespace { class myclass { // code here } } Is it possible????????? thanks to you all nagarajuepuri

    D D 2 Replies Last reply
    0
    • N nagarajuepuri

      hi, can we use two diffrent namespaces one after another within a single C# programs, for example something like following code.. Using system1; //namespace1 Using system2; //namespace2 namespace custom_namespace { class myclass { // code here } } Is it possible????????? thanks to you all nagarajuepuri

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You mean like this:

      using System;
      using System.Drawing;
      using System.Collections;
      using System.ComponentModel;
      using System.Windows.Forms;
      using System.Data;
      using System.Threading;

      namespace Number_Puzzle_Cs
      public class frmMain : System.Windows.Forms.Form
      {...

      Of course it is! Have you looked at the top of your Form code after creating a new Windows Form project? By default, it uses 6 namespaces:

      using System;
      using System.Drawing;
      using System.Collections;
      using System.ComponentModel;
      using System.Windows.Forms;
      using System.Data;

      namespace WindowsApplication5

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      N 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You mean like this:

        using System;
        using System.Drawing;
        using System.Collections;
        using System.ComponentModel;
        using System.Windows.Forms;
        using System.Data;
        using System.Threading;

        namespace Number_Puzzle_Cs
        public class frmMain : System.Windows.Forms.Form
        {...

        Of course it is! Have you looked at the top of your Form code after creating a new Windows Form project? By default, it uses 6 namespaces:

        using System;
        using System.Drawing;
        using System.Collections;
        using System.ComponentModel;
        using System.Windows.Forms;
        using System.Data;

        namespace WindowsApplication5

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        N Offline
        N Offline
        nagarajuepuri
        wrote on last edited by
        #3

        Thanks a lot, actually i am writing my C# code in notepad then i am compiling that code through command prompt. thanks once again nagarajuepuri

        D R T 3 Replies Last reply
        0
        • N nagarajuepuri

          Thanks a lot, actually i am writing my C# code in notepad then i am compiling that code through command prompt. thanks once again nagarajuepuri

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Yuk! But it's free, so I guess it's worth it! ;) RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • N nagarajuepuri

            Thanks a lot, actually i am writing my C# code in notepad then i am compiling that code through command prompt. thanks once again nagarajuepuri

            R Offline
            R Offline
            Richard Parsons
            wrote on last edited by
            #5

            Not very pretty but as was pointed out, it works. If you can't afford VS.NET or don't want to buy it may I humbly suggest Sharp Develop[^]. It's a free .NET development enviroment. I haven't used version 1 or whatever they are up to now but I did use it back in the .6 or .5 days and it was pretty good. Just a suggestion and it is free (both the suggestion and the app). -Richard

            1 Reply Last reply
            0
            • N nagarajuepuri

              hi, can we use two diffrent namespaces one after another within a single C# programs, for example something like following code.. Using system1; //namespace1 Using system2; //namespace2 namespace custom_namespace { class myclass { // code here } } Is it possible????????? thanks to you all nagarajuepuri

              D Offline
              D Offline
              Dariush Tasdighi
              wrote on last edited by
              #6

              Hi Dear, You can use a lot of namespaces if you want, but you must note that if there are two classes with the same name in two namespaces, You must write full address of your classs in your source code: For example: Suppose that you have two class with the name of Class1 in two namespaces (namespace1, namespace2) so if you want to use these class in your source code, You must write:

              Public Class2
              {
              public void SomeFunction()
              {
              namespace1.Class1 object1 = ...;
              namespace2.Class1 object2 = ...;
              }
              }

              I hope these notes be enough for you. Dariush Tasdighi http://www.IranianExperts.com Web Master

              1 Reply Last reply
              0
              • N nagarajuepuri

                Thanks a lot, actually i am writing my C# code in notepad then i am compiling that code through command prompt. thanks once again nagarajuepuri

                T Offline
                T Offline
                TRekrap
                wrote on last edited by
                #7

                You might try Mono, or the C# plugin for Eclipse, these are free and pretty powerful.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups