title: How to send a serialport as a parameter from one window form to another window form?
body: <p>I am working with serialport. I have two window forms and I need to use the serialPort in both forms. How can I send serialport from one form to the 2nd one as a parameter? My code looks like:</p>
  
  <pre><code>namespace SimpleSerial
  {
    public partial class Form1 : Form
    {
      Form2 pp = new Form2()
  
        public Form1()
        {
          InitializeComponent();
          pp.ShowDialog();
        }
        private void buttonStart_Click(object sender, EventArgs e)
        {
          serialPort1.PortName = "Com3";       
          serialPort1.BaudRate = 9600;
  </code></pre>
  
  <p>and code for 2nd Form:</p>
  
  <pre><code>namespace SimpleSerial
  {
    public partial class Form2 : Form
      {
        public Form2()
          {
            InitializeComponent();
            getAvailablePorts();
          }
  </code></pre>