Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,357 Categories: 12

Total Tutorial Views: 42,564,433

[C#] How to add .DLL references and use them

Tutorial Name: [C#] How to add .DLL references and use them  

Category: PC Tutorials

Submitted By: Skittle

Date Added:

Comments: 1

Views: 1,693

Related Forum: PC Building Forum

Share:

This tutorial will be linked to my previous one in which I showed you how to make your own .DLL Class Library.
Create your project in Visual Studio and find your Solution Explorer:

[ Register or Signin to view external links. ]

Right click on the object at the top of the file tree, click Add and click Reference:

[ Register or Signin to view external links. ]

Click Browse to find the .DLL that you want to add as a reference, make sure that that CheckBox next to it is checked and press Ok:

[ Register or Signin to view external links. ]

You will know that you have done this correctly as you will see your reference in the Solution Explorer under References:

[ Register or Signin to view external links. ]

At the top of your code, add:
using [Name of .dll];


[ Register or Signin to view external links. ]

The code to add will not always be the same as the name of the .dll, but it will be related. If you don't know, after you type using you can scroll through the list to find it.
Now, all you need to do is reference the Class Name with the Methods you want to call, as you have referenced the namespace at the top with using you only need to use ClassName.MethodName(); All you need to do is find the Class Name, which you can find by typing the namespace name, in this case my one is Skittle_Function_Library and you will be given all of the classes that are contained inside it, my only class is MathFunctions and my Methods inside MathFunctions are isOdd and isEven:

[ Register or Signin to view external links. ]
[ Register or Signin to view external links. ]

So to call the procedures, all you need to do is put ClassName.MethodName(); which in my case would be MathFunctions.isOdd:

if(MathFunctions.isOdd(21) == true)
{
    MessageBox.Show("21 is Odd!");
}

If you need any help with anything, feel free to PM me

Ratings

Current rating: 3.00 by 1 user
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"[C#] How to add .DLL references and use them" :: Login/Create an Account :: 1 comment

If you would like to post a comment please signin to your account or register for an account.

Island-TimePosted:

Nice tut, im going to look at some of your others as well!