I am writing a program which needs the namespace of the program but I cant seem to figure out how to retrieve it. I would like the end result to be in a string.
I wa
To add to all the answers.
Since C# 6.0 there is the nameof keyword.
string name = nameof(MyNamespace);
This has several advantages:
Note: This doesn't give the full namespace though. In this case, name will be equal to Bar:
namespace Foo.Bar
{
string name = nameof(Foo.Bar);
}