Reputation: 267030
if I don't put a namespace in my classes (vs.net 2008), which namespace do my classes get built under?
update Its strange, when I add a namespace I can't seem to reference the classes methods from my user control.
If I explicitly set a namespace, and add a 'using ...' in my control, I still can't see it!
How can this be?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
/// <summary>
/// Summary description for Globals
/// </summary>
public class Globals
{
public Globals()
{ }
public static string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString;
}
}
}
My control:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyStats : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
//etc.
Upvotes: 3
Views: 434
Reputation: 351526
If you do not provide a namespace then your type has no namespace. Remember that namespaces don't have any meaning post-compile. They simply get appended to the beginning of you type's name to create a longer name that has a greater probability of being unique.
Edit: I think that you may have two separate assemblies and one ought to be referencing the other but it is not. If two projects are in a single solution then the class viewer will show all types from all projects but that does not necessarily mean that ProjectA
references ProjectB
. In order to use the types from ProjectB
in ProjectA
you need to ensure that a project reference exists.
Upvotes: 4
Reputation: 18013
as you said, that class will not have any namespace, It will be accessible without a using clause.
Namespaces is a feature for putting order on your classes, by classifying, mostly according to their funcionality
EDIT
According to your update, i think your "global" class maybe putting trouble because of the global:: clause... would you mind to change the name of the class just to see if it works?
Upvotes: 1