调用 DLL 方法 - 方法名称不正确

Calling DLL Method - Method Name non correct

愚蠢的问题。 我正在开发一个简单的 DLL,它公开一个方法和一个调用该方法的控制台应用程序。两者都以 .NET 4.5 为目标,并且每个都有自己的解决方案。

DLL (MyLib.dll):

namespace MyLib{
    public static class MyClass{
        public static void MyMethod(){
}}} 

控制台应用程序:

using MyLib;

....

MyLib.MyClass.MyMethod();

也许我遗漏了一些简单的东西..但我想这样调用 MyMtehod:

using MyLib;

....

MyMethod();

我做错了什么?

谢谢

你想要using static:

using static MyLib.MyClass;

...

MyMethod();

The using static directive names a type whose static members and nested types you can access without specifying a type name.

The using static directive applies to any type that has static members (or nested types), even if it also has instance members. However, instance members can only be invoked through the type instance.

using static documentation

Try it online