0

I wanted to simply use the 2D string array arrayStr1[i,j] defined in class Form3 further in a class Form6.

namespace Win2
{
public partial class Form3 : Form
{
    Form2 fh;
    public Form3(Form2 call)
    {
        fh = call;
        InitializeComponent();
    }
    private void Form3_Load(object sender, EventArgs e)
    {
    }

    public void buttonRun_Click(object sender, EventArgs e)
    {
        string[,] arrayStr1 = new string[RowCount, ColCount];
    }

Error 1 says that there is no argument given that corresponds to the required formal parameter 'sender' of 'Form3.buttonRun_Click(object, EventArgs)'.

Error 2 says that 'Form3' does not contain a definition for 'arrayStr1' and no extension method 'arrayStr1', although it's defined in Form3.

namespace Win2
{
   public partial class Form6 : Form
   {
      Form2 fh;
      public Form6(Form2 call)
      {
         fh = call;
         InitializeComponent();

         Form3 data = new Form3(fh);
         data.buttonRun_Click();                  (error 1)
         string test = data.arrayStr1[1, 1];      (error 2)
     }
     private void Form6_Load(object sender, EventArgs e)
     {
     }

Thanks for your ideas.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
joe
  • 61
  • 2
  • 6
  • Already, I unsuccessfully tried the answers you mentioned. Obviously, class Form6 don't recognize the definition of string[,] arrayStr1. – joe Mar 10 '16 at 10:07
  • The error is "Object reference not set to an object instance" although I followed the examples. – joe Mar 10 '16 at 16:38

0 Answers0