C# Added an external reference but cannot use!

Posted on 2011-09-07
Last Modified: 2012-05-12

I'm very new to C# and not doing to well. I have added an external reference that is now showing in the solution explorer window. The thing is how do I reference it's properties and methods?

Question by:mcs26
  • 2

Accepted Solution

yesthatbob earned 500 total points
ID: 36498025
To get the namespaces and classes exposed by the reference, right-click on it in the solution explorer and select View in Object Browser. You can then simply refer to the classes defined in the reference in your code using the fully qualified namespace, or you can add a using statement at the top of your class file to reference the namespace as a shortcut. Here's an example of using the fully qualified namespace:

using System;

namespace ExampleCode
	class RegExExample
		System.Text.RegularExpressions.Regex myRegEx = new System.Text.RegularExpressions.Regex("what");
		System.Text.RegularExpressions.Match myMatch = myRegEx.Match("whatever");

Open in new window

And an example of the using statement:

using System;
using System.Text.RegularExpressions;

namespace ExampleCode
	class RegExExample
		Regex myRegEx = new Regex("what");
		Match myMatch = myRegEx.Match("whatever");

Open in new window


Author Comment

ID: 36498163
Hi yesthatbob,

Thanks for the reply. Is there a way to reference all the classes in the refrence in one go?

Thanks again,

Expert Comment

ID: 36498252
Well, no. You can reference all of the namespaces with individual using statements, but this is generally bad form - you should only add a using for the namespace you will actually be using. As for classes, you only refer to a class when you need it in code, so there's no need to reference "all of the classes" before hand.

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now