Determine the namespace of a C# file

How can I determine the namespace of a C# class if it is not defined in the file.

For example, from a class like this:

public partial class MyClass : System.Something
{


    protected void Page_Load(object sender, EventArgs e)
    {
        //do stuff

    }
        ....
}

The class is part of a project in visual studio 2012.

Jon Skeet
people
quotationmark

If no namespace is declared in the file, the source is in the "global" namespace. There's no namespace defaulting in C# as there is in VB.

All "real" code really should be in a namespace though, for sanity. (I write toy, throwaway code for Stack Overflow questions and blog posts in the global namespace, but nothing I'd want to keep.)

people

See more on this question at Stackoverflow