Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


C# Added an external reference but cannot use!

Posted on 2011-09-07
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

yesthatbob earned 2000 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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

661 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