hi friends,
i want to transfer the value of a 2-d array from one Form to another.
anybody have idea how to do this.

Like to pass a value from one form to another

public void TakeThis(int[][] array)
int[][] arrayOfIntegers = new int[1][2];
Form2 form2 = new Form2();

this code is not working

Sorry the right one is

public void TakeThis(int[,] array)
int[,] arrayOfIntegers = new int[1,2];
Form2 form2 = new Form2();

Hi there, I am trying to write a program that will the smallest number, largest number, sum and average when user inputs the numbers from the keyboard.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace findSmallestandLa
    class Program
        static void main()
       int[] arrayNum = new int[80];
       int[] largestNum;
       int[] smallestNum;
       int[] sum;
       int[] average;

       // Collect input from keyboard
       Console.WriteLine("Enter an integer");  
       arrayNum = int.Parse(Console.ReadLine());  

       largestNum = arrayNum;  
       smallestNum = arrayNum;  
       //now loop through the length of our array  
        for (int i = 1; i < arraySize; ++i)  
            //check if the current array index is larger  
            //than the largest number variable  
            if (arrayNum[i] > largestNum)  
                //if it is then that is the largest number  
                //(for this iteration)  
                largestNum = arrayNum[i];  
            //otherwise check to see if this array index  
            //is smaller than the smallest number  
            if (arrayNum[i] < smallestNum)  
                //that is our smallest number (for this iteration)  
                smallestNum = arrayNum[i];  
        //now print out the results  
        Console.WriteLine("Largest value is: {0}", largestNum);  
        Console.WriteLine("Smallest value is: {0}", smallestNum);  
        Console.WriteLine("The answer is " + (integer1 + integer2 + integer3));  
        Console.WriteLine("The answer is " + (sum / 3));   

I won't solve your problem!! your question solved try to do your task on your own, that's for your interest, by this way you won't get any useful!

hi friends,
i want to transfer the value of a 2-d array from one Form to another.
anybody have idea how to do this.

Here is one way that can do what you ask and more.


private frmOther varfrmOther; //Private var referencing frmOther declared at form level

//in frmMain’s Load event the form to be shown later (frmOther) is given a 
//reference to “this”, the parent form frmMain. 
//It’s in the load event here because I never close my frmOther until the end. 
//You may put it elsewhere.

varfrmOther = new frmOther(this); 

//Somewhere else in the code, when I want to show frmOther I have



private frmMain varParent; // private var - ref to frmMain passed into constructor
                    //declared at form level

//In the constructor for frmOther, I add the expected form object reference,
//passed when the form is instantiated ie (frmMain parentForm) as below.

public frmOther(frmMain parentForm)

varParent = parentForm; //I capture the frmMain reference (parentForm) 
//in a private variable varParent


//At this point both forms have a reference to each other
//frmMain has varfrmOther
//frmOther has varfrmParent

//Now each can access methods of the other

//If I want to pass objects such as arrays, I use a public property (get/set) to allow external access.

//For example in my frmOther..

private string[ , ] arrayX; //Two dimensional string array declared at form level

//Somewhere in code when I want to use it I instantiate the array

string[,] arrayX = new string[1,4];

//Then we just need public access
public string[,] FO_arrayX // Inter Form “FO_” just to remind me in code what this is.
    get { return this.arrayX;}  //”this” to identify the form level arrayX variable
    set {arrayX = value;}       

Is there any other way to do it???

Because on the same problem I used to pass the variable throgh cookies and reading it... But that was on a single variable passing schema only.

Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.