我有两个班级A和ClassB:
static class ClassA
{
static string SomeMethod()
{
return "I am a Static Method";
}
}
class ClassB
{
static string SomeMethod()
{
return "I am a Static Method";
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道ClassA.SomeMethod();和之间有什么区别ClassB.SomeMethod();
如果可以在不创建类实例的情况下访问它们,为什么我们需要创建静态类而不是仅使用非静态类并将方法声明为静态?