Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Nmaespace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bobby - 14 Sep 2007 18:54 GMT
I want to create a namespace.  I don't know how to do it.  I add a class in
my project. Should I add keyword namespace myNmaspace to it. or how can I do
it.

I want three files

myNmaespace.fileA
myNmaespace.fileB
myNmaespace.fileC
Where fileA.ca, fileB.cs,fileC.cs are my Classfiles.
ollebollebagare@gmail.com - 14 Sep 2007 19:09 GMT
> I want to create a namespace.  I don't know how to do it.  I add a class in
> my project. Should I add keyword namespace myNmaspace to it. or how can I do
[quoted text clipped - 6 lines]
> myNmaespace.fileC
> Where fileA.ca, fileB.cs,fileC.cs are my Classfiles.

Just surrond the class definition with the namespace definition, like
this:

namespace MyNameSpace
{
  class MyClass
 {
   ...
 }
}
Juan T. Llibre - 14 Sep 2007 19:09 GMT
re:
!> I want to create a namespace.  I don't know how to do it.

Just write the namespace's name in the different files,
and place all the files in the App_Code directory.

namespace GeometricShapes
{
   public class Square
   {
       public double Side;
   }
}

class Geometry
{
   void ShowSquare()
   {

// in this class you call the Square class of the GeometricShapes namespace :

        GeometricShapes.Square sqr = GeometricShapes.Square();
        sqr.Side = 24.55;
   }
}

If you want a *class* to span several files, make sure they're declared as *partial* classes :

With Partial declarations for a class you can split the class into several files:

MyClass1.cs:

public partial class MyClass
{
public void method1()
  {
// ...whatever you code here
  }
}

MyClass2.cs:

public partial class MyClass
{
public void method2()
  {
  }
}

Juan T. Llibre, asp.net MVPasp.net faq : http://asp.net.do/faq/foros de asp.net, en español :
>I want to create a namespace.  I don't know how to do it.  I add a class in
> my project. Should I add keyword namespace myNmaspace to it. or how can I do
[quoted text clipped - 6 lines]
> myNmaespace.fileC
> Where fileA.ca, fileB.cs,fileC.cs are my Classfiles.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.