passing array into a function

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 49
Reputation: kobi is an unknown quantity at this point 
Solved Threads: 0
kobi kobi is offline Offline
Light Poster

passing array into a function

 
0
  #1
Jul 26th, 2007
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
}
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 3
Reputation: vinod varma is an unknown quantity at this point 
Solved Threads: 0
vinod varma vinod varma is offline Offline
Newbie Poster

Re: passing array into a function

 
0
  #2
Jul 26th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 49
Reputation: kobi is an unknown quantity at this point 
Solved Threads: 0
kobi kobi is offline Offline
Light Poster

Re: passing array into a function

 
0
  #3
Jul 26th, 2007
where is the differance?
Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: passing array into a function

 
0
  #4
Jul 27th, 2007
he probably left off his method declaration

  1.  
  2. private void LoadScenario( string[,] Vars ) {
  3. }
  4.  
  5. //but if you only need one portion of the string in vars
  6.  
  7. private void LoadScenario(string Vars) {}
  8.  
  9. //then call like this..
  10. //assume we are inside of a class at this point
  11.  
  12. LoadScenario(vars[x,y]);
  13.  
  14. //where x is some int within bounds
  15. //where y is some int within bounds
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 49
Reputation: kobi is an unknown quantity at this point 
Solved Threads: 0
kobi kobi is offline Offline
Light Poster

Re: passing array into a function

 
0
  #5
Jul 27th, 2007
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC