Home > Mobile >  Global using directive in c#
Global using directive in c#

Time:11-30

I'd like to create a namespace in c# that can be found in any project. Not just the one that it is located in. like the system namespace. Is that possible and if yes I'd like to know how. I already googled and didn't find anything

CodePudding user response:

Classes in the System namespace are part of the Base Class Library (BCL) that gets included as part of the .NET Runtime. The only way for you to have your class be as globally accessible as, say, the System.String class, would be to convince Microsoft to add your class into their BCL. That is rare, but not unheard of. The IObservable<> interface is an example of a type that was added that way.

However, there are tons of classes that people are using every day without having them added to the BCL. If you're willing to accept one additional step for people to take with their projects, in order to leverage your project, you can example of class in library

adding refernce to project: adding refernce to project

example of using your own class library:

example of using your own class library

  • Related