Auto detecting Baud Rate of Arduino I'm trying to detect baud rate of Arduino Mega2560 by using C#. My code is below:

SerialPort SP=new SerialPort();
SP.BaudRate = 115200;


BaudRate is specified as a constant like this, but I would like to automatically detect it.

For instance, if Arduino code includes Serial.begin(xxxx), program should declare SP.BaudRate = xxxx.

How can I do it?
I'm not a C# programmer but this StackOverflow answer might be what you're looking for.