title: Getting an IEnumerable from a port.DataReceived Event and its subscriber method?
body: <p>I am trying to read data received from a device but I get the following error with line <code>DA.SetDataList(0, port.DataReceived);</code>: </p>
  
  <p><code>The best overloaded method match for Grasshopper.Kernel.IGH_DataAccess.SetDataList(int,System.Collections.IEnumerable) has some valid arguments.</code></p>
  
  <p>The SetDataList(int32, IEnumerable) is part of the Grasshopper Kernel. <code>port.DataReceived</code> is an event and therefore not a valid IEnumerable argument, it stores a list of data in an output parameter during GH_Component.SolveInstance(). I have set up a subscriber method portdatareceived which gives me strings. How can I get an IEnumerable from this method?</p>
  
  <pre><code>  SerialPort port;
  
     protected override void SolveInstance(IGH_DataAccess DA)
      {
      string gcode = default(string);
      DA.GetData(0, ref gcode);
  
      port = new SerialPort(selectedportname, selectedbaudrate, Parity.None, 8, StopBits.One); 
      port.DtrEnable = true;   
      port.Open();            
      port.DataReceived += this.portdatareceived;
  
      if (gcode == null)
      {
          AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Specify a valid GCode");
          return;
      }
      else
      {
          DA.SetDataList(0, port.DataReceived);
      }    
      }
  
    private void portdatareceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
      {
         string line = port.ReadExisting();
      }
  </code></pre>