Problem solve Get help with specific problems with your technologies, process and projects.

Global cases to the entire application

How can I make a class global to the entire application? In C++, could I use the "extern" keyword to aid in handling this?
The concept of global classes in C# is really just a simple matter of referencing the appropriate assembly containing the class. Once you have reference the needed assembly, you can refer to the class of choice either by it's fully qualified Type name, or by importing the namespace that contains the class.

If you want to import the namespace you can do so by the "using <Namespace>;" statement at the top of your source file. You will find examples of this in any C# source file generated when you insert a class, user control, or form into your project. Simply look to the top of the file to see lines such as "using System;" This allows the compiler to look into the specified namespace to find the Type you are after.

If you do not want to import the namespace by the "using" statement, you can simply refer to the Type using its fully qualified name. An example of this might be System.String. If this was a class you have defined it might appear like this. YourBusiness.YourApplication.YourClass.

If you are interested in reading up on namespaces, then open up the MSDN library or go online and lookup the "using" statement/keyword with C# as your filter. You should find all the reference and more in MSDN.


Dig Deeper on C# programming language

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.