Jump to content
  • Advertisement
Sign in to follow this  

[web] Making my own namespace

This topic is 4566 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 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;
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 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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!