[英]Define C# class outside of any namespace
是否可以在任何名称空间之外定义类 (而不是接口)?
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. Per juharr它最终在默认的全局命名空间中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.