954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

passing array into a function

Hello there,
I have an array of 2 dimensional which i need to pass to a funtion,
but every time i try to send to the funcation "LoadScenario" it fails.

maybe my syntax is wrong,please take a look

Thanks Ahead

string[,] Vars = newstring[5,4];
 
 
Vars[0,1]="Calculos";
Vars[1,1]=" 1";
Vars[2,1]=" 2";
Vars[3,1]=" 3";
 
Vars[0,0]="General";
Vars[1,0]=" 4";
Vars[2,0]=" 5";
Vars[3,0]=" 5";
Vars[4,0]=" 6";
 
LoadScenario(Vars);
 
------------------------
privatevoid LoadScenario(string Vars1)
{
//do something
}
kobi
Junior Poster in Training
57 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

string[,] Vars = newstring[5,4];


Vars[1,0]="Calculos";
Vars[1,1]=" 1";
Vars[1,2]=" 2";
Vars[1,3]=" 3";

Vars[0,0]="General";
Vars[0,1]=" 4";
Vars[0,2]=" 5";
Vars[0,3]=" 5";
Vars[0,4]=" 6";

LoadScenario(Vars);
try this

vinod varma
Newbie Poster
3 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

where is the differance?
Thanks

kobi
Junior Poster in Training
57 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

he probably left off his method declaration

private void LoadScenario( string[,] Vars ) {
}
 
//but if you only need one portion of the string in vars
 
private void LoadScenario(string Vars) {}
 
//then call like this..
//assume we are inside of a class at this point
 
LoadScenario(vars[x,y]);
 
//where x is some int within bounds
//where y is some int within bounds
Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

Thanks

kobi
Junior Poster in Training
57 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You