# [web] Making my own namespace

This topic is 4421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, Anyone who has used ASP.net knows at top there is a bunch of namespaces that you are currently using.. Like:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
ect..

I have a couple files with database classes and methods in them and would like to include them in my files the same way...but i don't know how.. For example I have the file "DatabaseStuff.cs" but I can't just add a using DatabaseStuff.cs; to the top...How come? Within DatabaseStuff.cs I have a "namespace DatabaseStuff", but I still just can't add "using DatabaseStuff;" to the top of the document like that...how do I get my DatabaseStuff.cs in the right form to include it like that? [EDIT] BTW, Let me know if this should be posted in .NET rather than Web Development...I guess you could say it's both... If so I'll delete this and repost it over ther [/EDIT] Thanks a bunch Kag1

##### Share on other sites
DatabaseStuff is just the filename. Unlike in the older Pascal on which C#'s namespaces are based, .NET supports a nested namespaces (allowing things like "mycompany.networking" and "theircompany.networking"). Because of this the name of the file no longer has any meaning.

So instead you need to define the namespace in the file, for example:

namespace DatabaseStuff
{
public class...
}

Then be sure the file is either part of your project or has been referenced.

• 10
• 17
• 9
• 14
• 41
• ### Forum Statistics

• Total Topics
631067
• Total Posts
2997740
×