Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an APi in C#? [closed]

Tags:

I have been doing programming, but now I'm facing a challenge. I'm on a project where I have to create an API in C# for my users. The basic process is that I have a C# code where I'm reading an XML file and obtaining the attributes and values that are between the tags. I achieved that and now I have to create consumable API for the same functionality. Is there any way through which I can learn to create API?

Basically I dont have any idea on how to move on with API. Any sort of examples would be of good use to me.

like image 662
Vikneshwar Avatar asked Jul 07 '12 12:07

Vikneshwar


People also ask

Can we use API in C language?

C language API. The C language Application Programmer's Interface (API) allows application programs to submit faxes to the Zetafax server for sending, and to control and monitor their progress as required. A simple function call is provided to submit an ASCII text file in a given format.

Can we create API in C++?

Normally yes. Generally: If source is to be available, use header only (if templates) or h +cpp. If no source, the best is DLL. Static libraries - you have to build for many compilers and one has to carry on your lib everywhere and link to it.


1 Answers

An API is just a way for other programmers to interface with your code. A C# class library could be an API, as could a web service, a WCF endpoint, etc. The easiest way to make one is to create a C# Class Library project, make sure it has public methods, and compile it to a .dll which you can distribute.

As mentioned by others, the Framework Design Guidelines are useful for some rules to follow.

One thing to keep in mind - and I wish this would get hammered into all new software developers - is that API design is fundamentally a usability problem. You're building a UI for the users of your software, and your users are other programmers.

This means that you want to follow all the general principals of UI/UX design - discoverability, making common tasks simple, etc.

Take advantage of XML comments to make sure the documentation is always there. Be sure that the most common tasks are easy to perform and that it's obvious how to do so. Make exceptions clean and include useful, actionable error messages. Think about what would make the consumer's life easier.

like image 54
MNGwinn Avatar answered Oct 11 '22 05:10

MNGwinn