title: Textbox Null Question
body: <p>So basically I'm trying to make a Windows Form Application to calculate the average of 4 test grades. However, in some classes, I may only have 3 tests. Without a value in all four test textboxes the program will not calculate the average.  I'm trying to figure out a way to code if the fourth text box has nothing in it, just ignore it and calculate the other 3.  My code is below:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace GradeCalc
  {
      public partial class Grades : Form
      {
          public Grades()
          {
              InitializeComponent();
          }
  
          private void Submit_Click(object sender, EventArgs e)
          {
              double test1;
              double test2;
              double test3;
              double test4;
              double average4;
              double average3;
  
              //Here, I'm trying to achieve:
              //if (t4 is empty)
              //{find the average of the first 3 textboxes}
  
              if (t4.Text == null)
              {
                  test1 = double.Parse(t1.Text);
                  test2 = double.Parse(t2.Text);
                  test3 = double.Parse(t3.Text);
                  average3 = ((test1 + test2 + test3) / 3);
                  tavg.Text = average3.ToString("00.00");
              }
                  //Here, I'm trying to achieve:
                  //if (t4 is not empty)
                  //{ calculate the average of all 4 textboxes}
  
              else
                  if (t4.Text != null)
                  {
                      test1 = double.Parse(t1.Text);
                      test2 = double.Parse(t2.Text);
                      test3 = double.Parse(t3.Text);
                      test4 = double.Parse(t4.Text);
                      average4 = ((test1 + test2 + test3 + test4) / 4);
                      tavg.Text = average4.ToString("00.00");
                  }
          }
      }
  }
  </code></pre>
  
  <p>I do not have a lot of experience with C#, so any help would be appreciated thanks.</p>