Reputation: 553
Dumb problem. I am developing an easy DLL which expose one method and a Console Application which call the method. Both are targeting .NET 4.5, and each one is on a own solution.
DLL (MyLib.dll):
namespace MyLib{
public static class MyClass{
public static void MyMethod(){
}}}
CONSOLE APP:
using MyLib;
....
MyLib.MyClass.MyMethod();
Maybe I am missing something easy.. but I would like to call MyMtehod like this:
using MyLib;
....
MyMethod();
What am I doing wrong ?
Thanks
Upvotes: 0
Views: 29
Reputation: 38870
You want 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.
Upvotes: 1