title: Converting QBasic CHR$(13)+CHR$(10) to C#
body: <p>I'm trying to pass a straight ASCII text command through my serial port, something like this:</p>
  
  <pre><code>string cmd = "&lt;ID00&gt;&lt;PA&gt;Hello World. ";
  template.Serial.WriteLine(cmd);
  </code></pre>
  
  <p>Serial being a SerialPort property reference.  I've also tried 'Write(cmd)' but even though the serial port is open the command never seems to go through. I've found that I'm supposed to add a Carriage return (cr) and a Line Feed (lf) to the end of the message, but I don't know how to do this in C# short of converting everything to bytes but It needs to be passed as ASCII Text from my understanding of the protocol.  </p>
  
  <p>I found someone's QBasic source that looks like this:</p>
  
  <pre><code>100 OPEN "COM1:9600,N,8,1,CS,DS,CD" AS 1
  200 PRINT #1,"&lt;ID00&gt;";:REM SIGN ADDRESS, 00 FOR ALL
  210 PRINT #1,"&lt;PA&gt;";:REM PAGE "A" (MESSAGE NUMBER, A-Z)
  220 PRINT #1,"&lt;FQ&gt;";:REM OPTIONAL DISPLAY MODE, (FA-FZ), "APPEAR"
  230 PRINT #1,"&lt;CB&gt;";:REM OPTIONAL COLOR CHANGE, (CA-CZ), "RED"
  240 PRINT #1,"Hello World";:REM TEXT
  250 PRINT #1, CHR$(13)+CHR$(10);:REM MUST END IN CARRIAGE RETURN/LINE FEED
  </code></pre>
  
  <p>So how would you convert CHR$(13)+CHR$(10) to characters that you append to the end of a string line in c# code to be sent through a serial port?</p>