Using a class file / link?

If you are using an assembly reference (myExample.dll) you add it at the top

using myExample;

      

Now if you create a class file, how do you refer to it?

+2


source to share


4 answers


Well, in your class file, you have the following:

namespace myNamespace
{
    public class MyClass
    {
        public void MyMethod() { }
    }
}

      

Let's assume you have this in an assembly named MyDll.dll

. You would use it like this:



  • You add a link to MyDll.dll

    in the solution explorer
  • You include the namespace with using myNamespace;

  • Then you can use your class by doing MyClass test = new MyClass();

If you didn't add a namespace like I said in 2., you would use your class:

myNamespace.MyClass test = new myNamespace.MyClass();

      

+10


source


You want to add a using statement for whatever namespace you want to import. Navigate to the file and see which namespace gets moved to the class you're interested in.



0


source


You just include the file when you compile the assembly.

You may need to add an operator using

.

0


source


Your question is somehow incomprehensible.

When you define a new class, in another dll it is enough to specify this DLL.

Please note that you will not be able to access this class due to its access. Define your class with a keyword public

.

0


source







All Articles