using API's for programming

Please explain how API(s) can be written and then  used in others modules. please use C# as an example ! thank s
Who is Participating?
kmaicorpConnect With a Mentor Commented:
C# uses managed code, so it's pretty easy to apply API to it. First you would have to create a DLL project, create your classes and compile. Then give the DLL to someone who would use your DLL in their library. Then to use your DLL, all they need to do is add a reference to your DLL from their project, they can then call the methods and instantiat the classes you have in your DLL.

As an example:

Library Class:

namespace MyOwnNamespace
  public class Foo
     public void Bar() {  } // Do something
Compile this into a DLL, lets say we call it FOO.DLL

Now create a new project (console or window app is fine). In your solution explorer, right click on references and select add new. Then select the browse tab, find your newly created dll (FOO.DLL) and add it. Now you can access the classes in your library calling it out. For exple:
  MyOwnNamespace.Foo myFoo = new   MyOwnNamespace.Foo();

You can add a using statement to the top of your file if you dont want to type the full name of the class.

Good luck!
Please explain what you are really asking here.  What are you trying to do.  Because your question is Soooooooo broad that it sounds like it may be homework or for a course....
All Courses

From novice to tech pro — start learning today.