title: clear buffer contents in C#
body: <p>I am working on a program where I continously  send control commands to control the AR.Drone. I am writing the contents to a buffer and sending to a socket.
  When I execute the program the drone is  not behaving as required. I think this may be due to contents queued in the buffer that were not sent.
  So I want to clear the contents of buffer before sending any new command. How can I do this?
  In C we can use <code>flush()</code>. What is it in C#?
  My code is:</p>
  
  <pre><code>    Socket sending_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
  
      IPAddress send_to = IPAddress.Parse("192.168.1.1");
      IPEndPoint sending_end_point = new IPEndPoint(send_to, 5556);
      string buff1;
      byte[] buff2;
  </code></pre>
  
  <p>I am writing a string to a text file upon each button press. I then read the text file to retrieve the content and based upon the content send the corresponding command.And in text file each time I am overwriting the previous string so there will be only one string in text file.</p>
  
  <pre><code>    switch (choice1)
                      {
                          case "takeoff":
                              {
  
                                  System.Console.WriteLine("send take-off command");
                                  buff1 = null;
                                  buff2 = null;
                                  buff1 = String.Format("AT*REF={0},290718208\r", seq);
                                  buff2 = Encoding.ASCII.GetBytes(buff1);
                                  sending_socket.SendTo(buff2, sending_end_point);
                                  seq = seq + 1;
                                  break;
  </code></pre>