Csharp playground

The .cs file that you posted is only one of the files in a C# project. I'm not inclined to want to reproduce (by guessing) those other files. You can zip up your whole solution directory (then delete the pdb files from the zip file) and attach that zip file to your post.

Is that C# file the code with the errors or the fixed code? If it is the fixed code, what changes did you need to make?

Adding some calls to Console.WriteLine() and running the C# code in debug mode would tell you whether the Arduino's serial port is detected and what, if any response is received.

Which Arduino are you trying to detect? That code would detect a Leonardo, for instance.