You have issues with both the C# code and the Arduino code.
for (int i = 0; i < (10000 * port.BytesToRead) / port.BaudRate; i++)
; //Delay a bit for the serial to catch up
This is useless. The compiler is smarter than you. It will see that the loop does nothing and remove it. You should too.
string name = "/dev/ttyACM0";
What OS are you running on? As far as I know, C# only works on Windows, and this is not a Windows serial port name.
On the Arduino:
mySwitch myLib = mySwitch();
Lose the parentheses.
Class names generally start with a capital letter (Serial, Client, Server, etc.). You haven't shown your code for your library, so we have no clue what it does.
but myLib doesn't seems to reply
Show the code. Otherwise, you're on your own.
while (Serial.available())
{
delay(1); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
zoomkat's protestations carry little weight with me. You need to add an end-of-packet marker, and read serial data until that end of packet marker arrives. Get rid of the useless delay.
As I said everything works perfect from serial monitor but when it gets to my C# serial monitor it doesn't work.
As has been said before, "it doesn't work" is whining. "It does this, but I want it to do that" is useful information. We don't do well with whining here. At least, I don't.