arrays from other functions

  • Thread starter Thread starter reedr
  • Start date Start date
R

reedr

I'm stuck with trying to reference an array of datagridviews that i
created at runtime. It works fine when I reference them within the
function they were created, but now I want to refer to them in another
function. They are both public functions so I just was wondering what
I need to do to access this array (or any variable for that matter) in
another function without creating it outside of the first function.
DataGridView[] Tools = new DataGridView[nToolChangeCalls];
 
I'm stuck with trying to reference an array of datagridviews that i
created at runtime. It works fine when I reference them within the
function they were created, but now I want to refer to them in another
function. They are both public functions so I just was wondering what
I need to do to access this array (or any variable for that matter) in
another function without creating it outside of the first function.
DataGridView[] Tools = new DataGridView[nToolChangeCalls];

There are two basic ways to share data between two functions:
1) pass the data from the first function to the second as an argument
2) keep a reference to the data in a mutually accessible store e.g. if
they are both public methods in the same class, keep a private field
that they both use
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top