943,898 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 12291
  • C# RSS
Jul 26th, 2007
0

passing array into a function

Expand Post »
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
}
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kobi is offline Offline
57 posts
since Nov 2006
Jul 26th, 2007
0

Re: passing array into a function

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinod varma is offline Offline
3 posts
since Jul 2007
Jul 26th, 2007
0

Re: passing array into a function

where is the differance?
Thanks
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kobi is offline Offline
57 posts
since Nov 2006
Jul 27th, 2007
0

Re: passing array into a function

he probably left off his method declaration

C# Syntax (Toggle Plain Text)
  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
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 27th, 2007
0

Re: passing array into a function

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

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: populte treeView control with xml file
Next Thread in C# Forum Timeline: a few days in C# and already needs helP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC