473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

pass an array from class to class

158 100+
How do i pass an array from one class to another in c#, or if there is a better way of doing what i am trying to do. Right now this is what i have.
Expand|Select|Wrap|Line Numbers
  1. namespace Proj
  2. {
  3.     public partial class frmFinalProj : Form
  4.     {
  5. int[,] table = new int[10, 9];
  6. }
......
Expand|Select|Wrap|Line Numbers
  1. private void btnSave_Click(object sender, EventArgs e)
  2.         {
  3.             string dir = @"C:\C# 2008\Proj\";
  4.             string path = dir + userName + ".txt";
  5.  
  6.             if (!Directory.Exists(dir))
  7.                 Directory.CreateDirectory(dir);
  8.  
  9.             if (File.Exists(path))
  10.             {
  11.               //will fill in later
  12.             }
  13.             if (!File.Exists(path))
  14.             {
  15.                 File.Create(path);
  16.             }
  17.  
  18.             FileProcessing process = new FileProcessing();
  19.             process.SaveSoduko(path, table);
  20.         }
  21.  
  22. public class FileProcessing
  23.     {
  24.  
  25.         public void SaveSoduko(string path,int[,] table)
  26.         {
  27.             StreamWriter textOut = new StreamWriter(new FileStream(path, FileMode.Create, FileAccess.Write));
  28.  
  29.             for (int x = 0; x < 9; x++)
  30.             {
  31.                 for (int y = 0; y < 9; y++)
  32.                 {
  33.                     textOut.Write(table[x, y]);
  34.                 }
  35.             }
  36.         }
  37.     }
  38.  
  39. }
  40.  
Any help is greatly appreciated
Apr 30 '08 #1
0 846

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Kenny | last post by:
Hello, can anyone tell me how to pass an array to a function ? I have this function , part of my class. It works if I do not put in int a everywhere , but obviously , I need to add an array so I...
41
by: Berk Birand | last post by:
Hi, I am just learning about the array/pointer duality in C/C++. I couldn't help wondering, is there a way to pass an array by value? It seems like the only way to do is to pass it by...
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
7
by: liyang3 | last post by:
Hi, I have Class A, B and C. Class A has an instance of B. Class B has an instance of C. In the instance of C, it generates some data that need to be passed back to Class A. But Class C...
1
by: Williams.sam | last post by:
I am wondering if there is a way (maybe via Marshalling ) to pass an array of Objects of some C# defined class to VB. I am already launching a C# form from VB with simple call backs using a basic...
3
by: Brett | last post by:
I have several classes that create arrays of data and have certain properties. Call them A thru D classes, which means there are four. I can call certain methods in each class and get back an...
4
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: ...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.