Click here to Skip to main content
15,745,916 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can an array, with its value intact be transferred from one function to another...?

What I have tried:

Step 1: First i created a class :- [ CrVw.cs]
Form containing okay button listbox combo box and AddTable button.
Step 2: In the form i just added the columns of the selected table to the
listbox selectedindexchanged event
step 3: In tthe AddTable button event
i selected the columns of the specified table in an array and displayed in a
msg box. Now how i will be able to transfer the content of the array to
another function... I did it thisway but without result
In the dataview.cs file
public void TransferViewData(string [,] args)
     string [,] colHead=null;
     int h=colhead.GetLength(1);

     for(int k=0;k<=5;k++)
         for(int i=1;i<=h+1;i++)
                  nint=1;   ///(nint is a variable declared before in the
                            /// code)
                   var str22=colHead[k,i];

}  // End of this block....

step 4: In the Form load event of DataView.cs
i called transferDataView(CrVw.str);
// str is a static string array of two dimensions which can hold the data
provided by the CrVw.cs AddTable button.
Note : error ArrayIndexOutOfBounds.....because CrVw.str is null....why...?
Updated 23-Apr-22 11:34am
PIEBALDconsult 24-Apr-22 13:06pm    
By reference.
Member 12712527 25-Apr-22 22:34pm    
Arrays are passed by reference....automatically...

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900