Reputation: 53
Is it possible to define a class (not interface) outside of any namespace?
Upvotes: 5
Views: 2705
Reputation: 1890
Ran a test and yes you can. Here's my code built off of a Console App:
using System;
using System.Text;
namespace With_Console_App
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This will output something: ");
Console.ReadLine();
some.Print();
Console.ReadLine();
}
}
}
class some
{
public static void Print()
{
Console.WriteLine("something");
}
}
Yes, you can define a class outside of a namespace. Per juharr it ends up in the default global namespace.
Upvotes: 7