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.
[code=cpp]
namespace Proj
{
public partial class frmFinalProj : Form
{
int[,] table = new int[10, 9];
}[/code]
......
[code=cpp]
private void btnSave_Click(o bject sender, EventArgs e)
{
string dir = @"C:\C# 2008\Proj\";
string path = dir + userName + ".txt";
if (!Directory.Exi sts(dir))
Directory.Creat eDirectory(dir) ;
if (File.Exists(pa th))
{
//will fill in later
}
if (!File.Exists(p ath))
{
File.Create(pat h);
}
FileProcessing process = new FileProcessing( );
process.SaveSod uko(path, table);
}
public class FileProcessing
{
public void SaveSoduko(stri ng path,int[,] table)
{
StreamWriter textOut = new StreamWriter(ne w FileStream(path , FileMode.Create , FileAccess.Writ e));
for (int x = 0; x < 9; x++)
{
for (int y = 0; y < 9; y++)
{
textOut.Write(t able[x, y]);
}
}
}
}
}
[/code]
Any help is greatly appreciated
[code=cpp]
namespace Proj
{
public partial class frmFinalProj : Form
{
int[,] table = new int[10, 9];
}[/code]
......
[code=cpp]
private void btnSave_Click(o bject sender, EventArgs e)
{
string dir = @"C:\C# 2008\Proj\";
string path = dir + userName + ".txt";
if (!Directory.Exi sts(dir))
Directory.Creat eDirectory(dir) ;
if (File.Exists(pa th))
{
//will fill in later
}
if (!File.Exists(p ath))
{
File.Create(pat h);
}
FileProcessing process = new FileProcessing( );
process.SaveSod uko(path, table);
}
public class FileProcessing
{
public void SaveSoduko(stri ng path,int[,] table)
{
StreamWriter textOut = new StreamWriter(ne w FileStream(path , FileMode.Create , FileAccess.Writ e));
for (int x = 0; x < 9; x++)
{
for (int y = 0; y < 9; y++)
{
textOut.Write(t able[x, y]);
}
}
}
}
}
[/code]
Any help is greatly appreciated