0

I created a class library with .Net 6.0 which looks like this:

namespace MyLib
{
    public static class MyLib {

        public static void someFunction() { }
    }
}

I created a nuget package and added that package to another application. My expectation was that I would put using MyLib at the top of a class and then could call MyLib.someFunction() in the code. But instead, I always have to call MyLib.MyLib.someFunction(), with the using-directive doing nothing.

Can someone explain to me what I'm doing wrong?

TigersEye120
  • 664
  • 1
  • 9
  • 28
  • are the static class and the namespace really share `MyLib` name? – Bagus Tesa Jul 05 '22 at 08:19
  • 5
    While the C# compiler does allow it (_stupid, stupid..._), you should always ensure a class's name does not equal its namespace name. – Dai Jul 05 '22 at 08:21
  • 2
    Namespace same as Classname - I found that this can (and will) cause some trouble. – Fildor Jul 05 '22 at 08:21

0 Answers0