Unfortunately, chess engine doesn't work like what you expect. In particular, there is no such thing as API in the chess engine world. That's because calculating a chess move takes time, and it'll be insane to block your function call until you can get the move.
Chess engine almost always do the works in its own thread or process. You might need to learn how to interact with a thread/process. You'll also need to learn UCI chess protocol. I don't think there is a wrapper for you, but maybe there is just that I don't know.
Stockfish is a C++ engine, so you might need to wrap it with a managed C++ layer for C#. There is a Stockfish port on C#, but it's not as good as the original. However, you don't even need a source code to do your works. You could also take a closed engine such as Houdini.
General steps:
- Download a compiled binary (*.exe). It can be anything like Houdini, Komodo or Stockfish. You don't have to compile the source code yourself.
- Use Process.Start in C# to start a process of the chess engine
- Talk with the child process like here
- Try to send a UCI message like this:
isready
The isready UCI command is like pinging the chess engine. You should hear something back if your implementation works. Please take a look at the UCI documentation, you'll find it on Google. Once you know your code works. Try this:
ucinewgame
go move time 1000
This gives the engine one second to make a move. You will get something like this:
bestmove e2e4 ponder e7e5