title: C# get current namespace dynamically in a variable
body: <p>I want to get current namespace in a variable. 
  I have the following piece of code.</p>
  
  <pre><code>Assembly assembly = Assembly.GetExecutingAssembly(); 
  foreach(Type type in assembly.GetTypes()) 
  { 
      Console.WriteLine(type.Namespace); 
  } 
  </code></pre>
  
  <p>By executing it, it show me the following:</p>
  
  <pre><code>System.Type[]
  mynamespace
  mynamespace
  mynamespace
  mynamespace
  mynamespace.Properties
  mynamespace
  ....
  </code></pre>
  
  <p>I also have this piece of code that return me the current namespace in string.</p>
  
  <pre><code>string name = MethodInfo.GetCurrentMethod().ReflectedType.Namespace;
  </code></pre>
  
  <p>What I want to do is to get the namespace, pass it to a variable. so the variable can use that namespace as reference to access the namespace methods and variables. basically I want to do something like this. 
  I am looking for something like this:</p>
  
  <pre><code>this.GetCurrentNameSpace().variable1.ToString(); 
  </code></pre>
  
  <p>sounds funny but thats the kind of method/code I am looking for</p>
  
  <p>How can I do it?</p>