Computer problems,Computer help
*AX SOFT>>>Programming & Design

[C#] How do I get the name of the current program's namespace?


In C#, how do I get the name of the current program's namespace?

Sorry, I left out some important details in my question as these are not actual answers I wanted.

My question would have been: "how do I get the name of the current program's namespace as a string?"

Here's the new question for some extra opportunities:
http://answers.yahoo.com/question/index;...

Hello,

To get the current program (application) namespace, I assume you mean the "default namespace", you do the following:

1) Open Visual Studio
2) Load your Project (solution) to the Workspace
3) In the Solution Explorer, you double click on properties, OR right click on the project and choose properties.
4) A window will show, and in the Applications Tab, you will see "Default namespace"

Remember, that namespace is what VisualStudio says it is. But within your application, you can have more than one namespace. So whenever you create a new class or file, that "default namespace" will be used.

If you change that namespace from the project properties to something else, it will NOT change your projects namespace in your sourcecode. You will have to refactor (rename) the name space to the new renamed namespace.

If you want the current entry point namespace, you look where your main application is executed from the main method, and the namespace could be defined above as:

namespace HelloWorld {

}

Remember an application could have as much namespaces you want, and it could even have NO namespaces. Namespaces lets you organize code and gives you a way to create globally unique types. Therefore it is optional, but it is better to use since it will make it more organized. Hence, you cannot state a program must have one namespace, it could and it could not. And if it does, it could consist of 1000 namespace, BUT there is one default namespace as I explained earlier that would be the only namespace if the user didn't create/remove any other namespaces.

Good Luck, I hope that clariffied some stuff

Eh, now I understand what you needed. I answered your other question. You will need to use Reflection and grab the Current Assembly and fetch the Namespace from the Type. Report It

Thanks Mohamed.Mansour, I got it working now! I will try to choose you as the best answerer as quickly as possible as soon as the Yahoo! Answers timer runs out. :) Report It

http://www.fincher.org/tips/Languages/cs...


http://msdn2.microsoft.com/en-us/library...

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Does the Linux Professional Institute Certification (LPIC) program have an advantage in trying to find a job?

    Hello, (ANS) If you stand back a little here and bear in mind that with the cost of computing rising especially in terms of business's & companies & Corporations having to pay out v...

  • Are there any good resources for creating pi calculation programs?

    Well, I found a recursive arctan formula. The General Formulae We have just seen that there are infinitely many formulae for Pi using the Fibonacci numbers! They are: Pi/4 = arctan(1) = arcta...

  • Can you PLEASE make me a banner?

    Write me at my email addy and I'll see what I can do to help you.

    ...
  • I got the system time using java.sql.time package,i want time before 12:00 O'clock print good morning how?

    Here's a start. package com.yahoo.answers; import java.util.Date; public class GoodDay { public static void main(String[] args) { Date now = new Date(); int hours = now.get...

  • Visual Basic???

    Where are you inserting the code that you just showed us > MsgBox("Unable to Perform Function.",0,"Error") IT has to be in the OnClick Event of the Button on the form. ...

  • What is a .reg file?

    hi, try this link to download .reg file.. ...

  • CSS: link code help!?

    You forgot to close your <a> tag. <a href= "aboutme-mock-up-CSS.html"> about me </a></div>

    ...
  • How can i put an affilite choice in my website?

    You need a website with database support. Normally these kind of websites uses PHP and MySQL so you can go for Linux hosting. Try www.hostgator.com its a good one.. I am using the same service...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster