fork download
  1. public static void Main()
  2. {
  3. string name;
  4. string message;
  5. StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
  6. Thread readThread = new Thread(Read);
  7.  
  8. // Create a new SerialPort object with default settings.
  9. _serialPort = new SerialPort();
  10.  
  11. // Allow the user to set the appropriate properties.
  12. _serialPort.PortName = SetPortName(_serialPort.PortName);
  13. _serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate);
  14. _serialPort.Parity = SetPortParity(_serialPort.Parity);
  15. _serialPort.DataBits = SetPortDataBits(_serialPort.DataBits);
  16. _serialPort.StopBits = SetPortStopBits(_serialPort.StopBits);
  17. _serialPort.Handshake = SetPortHandshake(_serialPort.Handshake);
  18.  
  19. // Set the read/write timeouts
  20. _serialPort.ReadTimeout = 500;
  21. _serialPort.WriteTimeout = 500;
  22.  
  23. _serialPort.Open();
  24. _continue = true;
  25. readThread.Start();
  26.  
  27. Console.Write("Name: ");
  28. name = Console.ReadLine();
  29.  
  30. Console.WriteLine("Type QUIT to exit");
  31.  
  32. while (_continue)
  33. {
  34. message = Console.ReadLine();
  35.  
  36. if (stringComparer.Equals("quit", message))
  37. {
  38. _continue = false;
  39. }
  40. else
  41. {
  42. _serialPort.WriteLine(
  43. String.Format("<{0}>: {1}", name, message));
  44. }
  45. }
  46.  
  47. readThread.Join();
  48. _serialPort.Close();
  49. }
  50.  
  51. public static void Read()
  52. {
  53. while (_continue)
  54. {
  55. try
  56. {
  57. string message = _serialPort.ReadLine();
  58. Console.WriteLine(message);
  59. }
  60. catch (TimeoutException) { }
  61. }
  62. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,14): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty