If you use a you assembly reference (myExample.dll), you add like this to the top
using myExample;
Now if you create a class file, how do you reference it?
If you use a you assembly reference (myExample.dll), you add like this to the top
using myExample;
Now if you create a class file, how do you reference it?
You want to add a using statement for whatever namespace you want to import. Go to the file and see what namespace it wraps the class you're interested in.
You just include the file when compiling the assembly.
You may have to add a using
statement too.
Your question is somehow unclear.
When you define a new class, in another dll, it is enough to reference that dll. However you might be unable to access that class because of its accessors. So define you your class with a public
keyword.
Well, in your class file you have the following:
namespace myNamespace
{
public class MyClass
{
public void MyMethod() { }
}
}
Let's assume that you have this in an assembly named MyDll.dll
. You'd use it as follows:
MyDll.dll
within the solution explorerusing myNamespace;
MyClass test = new MyClass();
If you don't add the namespace like I said in 2., you'd use your class like:
myNamespace.MyClass test = new myNamespace.MyClass();