Well, that depends on how sensitive jack is. Seriously, what the hell are you talking about ? To control an external real world device, you need an interface. Then you code to that interface. you can't just ask for C# code that magically controls a piece of hardware.
Do you mean a USB device ? You can tell if it's present or not, but how is not present and unplugged different ?
This[
^] is how programmers deal with issues like this.