I'm guessing you can use this:
Wrapper Library for Windows MIDI API[
^]
However, speaking from experience, the issue I found with that actually has to do with the latency of the output. The midi is fine, but without using ASIO the audio is noticeably delayed as soon as you do *any* significant processing on the audio and that makes it impossible to create any kind of reasonable audio app in C#
However, there are other options, all with drawbacks and advantages. Synthmaker - now Flowstone is excellent for simple coding of surprisingly intricate VSTs and FLStudio plugins but it's MIDI support is not great.
The best option I've found from experience is (and I don't like it admittedly) is to use C++. You can rely on the STL and even boost libraries to help you along - and I recommend it, particularly if you're doing MIDI because containers and iterators are the order of the day if you're doing any midi sequencing in C++.