是否可以在任何命名空间之外定义一个类(不是接口(interface))?
最佳答案
运行测试,是的,你可以。这是我基于控制台应用程序构建的代码:
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");
}
}
是的,您可以在命名空间之外定义一个类。根据 juharr,它最终位于默认的全局命名空间中。
关于c# - 在任何命名空间之外定义 C# 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36460263/