Reputation: 125
does a DLL(dynamic linking library) contains more than one class? if it contains how to get the classes and their methods separately in .net in c#
Upvotes: 2
Views: 569
Reputation: 47377
I think you got a downvote because the the simplicity of your question.
Yes a DLL (assembly) can contain multiple classes. You access them with the "dot".
MyDll.MyNamespace.SpecialClass
Sometimes you have to initiate the class to access the methods
SpecialClass special = new MyDLL.MyNamespace.SpecialClass();
special.MyCustomMethod();
First of course, you have to reference the assembly in your Project. Then you can access the Classes and Methods (and Structs, Enums, etc)
Upvotes: 0
Reputation: 58261
A DLL can contain more than one class. To do this cleanly, I would create a Class Library project in Visual Studio and create a single file for each class. Each class that is in the project will end up in the DLL when you are finished.
Once you do that, you can add a reference to this DLL (more commonly referred to as an Assembly) from another project. When you add using MyNewNamespace
you will be able to access them without having to type the namespace every time.
Upvotes: 0
Reputation: 218722
Oh yes.A dll can hold many classes.You can create an object of the class and invoke the methods of it OR use the ClassName.MethodName() approach if its a static class.
A class library can contain any number of classes.You can create a class for representing each entity in the app.(Ex: Student,Course..)
Ex:
MyStudent objStudent=new MyStudent(); // creating object
objStudent.GetUser("somename"); // calling method
calling method of another class in the class library
MyCourse objCourse=new MyCourse (); // creating object
objCourse.GetCourse("english"); // calling method
OR (for Static)
MyStudent.GetUser("somename")
MyCourse..GetCourse("english");
Upvotes: 1
Reputation: 12119
Class libraries can contain one or more classes.
If a method is static you can call it directly, otherwise you'll have to instantiate the class and call methods of that instantiated object...
Upvotes: 0
Reputation: 564413
In .NET, it's more common to think of "DLLs" as Assemblies. A single assembly can contain any number of types (multiple classes, enums, structs, etc).
You use these by adding a reference to the assembly in the project where you want to use the types. You can also, optionally, add a "using NamespaceFromDll;" at the top of the C# (or Import in VB.NET) to allow the classes to be used without fully qualifying their names.
If you need to see what types are available from within a DLL, you can inspect the public types via the Object Browser.
Upvotes: 1