title: how to return null if picture box is null else return picture byte
body: <p>in my following code i want to return data the null if my PictureBox(pbspic) is null else if PictureBox(pbspic) contains a picture I want data to return picture byte so that I can save null or picture in my database </p>
  
  <pre><code>using (MemoryStream stream = new MemoryStream())
          {
              Bitmap bmp = new Bitmap(pbspic.Image);
              bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
              stream.Position = 0;
              byte[] data = new byte[stream.Length];
              stream.Read(data, 0, data.Length);
              return data;
          }
  cmd.Parameters.Add("@Photo", SqlDbType.VarChar).Value = data;
  dm2.ExecActQuery("StudentsInsert", cmd);
  </code></pre>