MilesMorales MilesMorales - 2 months ago 5x
C# Question

Putting a class name = namespace, in using

using BusinessTask = MyProject.WinService.Tasks.Core.BusinessTask;

I understand from the above BusinessTask class can now be used, however I'm wondering what reasons perhaps the author didn't just put:

using MyProject.WinService.Tasks.Core;

Is it perhaps to be selective on the exposure of that location since "Core" has many other classes?


BusinessTask may exist in several namespaces. To avoid full namespace path specification near each BusinessTask usage you can explicitly say:

using BusinessTask =  MyProject.WinService.Tasks.Core.BusinessTask;

and compiler will know that when you are using BusinessTask it should pick it up from MyProject.WinService.Tasks.Core namespace.

Here is a great example How to handle same class name in different namespaces?