Advertisement Jump to content
Sign in to follow this  

[web] Making my own namespace

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Anyone who has used 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;
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 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 this post

Link to post
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!