C Sharp help? 
	 
	
		| Author | 
		Message | 
	 
		 
		RealityFix
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Nov 07, 2009 5:46 pm    Post subject: C Sharp help?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Not really help... more like i need an explanation as to why this is working xD 
 
 
	  | C#: | 	 		  
struct SnowFall
         {
            public int amount;
             public String City;
             public int Year;
         }
        SnowFall [, ] Chart =  new SnowFall [100, 100];
 
        SnowFall [] CityContainer =  new SnowFall [7];
 for (int rows =  0; rows <=  6; rows++ )
                {
                     tempr  [rows ] = line. Split(' ')[rows ];
 
                    CityContainer [rows ]. City = tempr [rows ];
 
                    OutputBox. Text += CityContainer [rows ]. City +  "\t";
                     for (int c =  1; c <=  4; c++ )
                    {
                        if (rows ==  0)
                        {
                            temp [c ] = line. Split(' ')[c ];
 
                            CityContainer [c ]. Year =  int. Parse(temp [c ]);
                            
                         }
                        else
                        {
                            temp [c ] = line. Split(' ')[c ];
 
                            Chart [rows, c ]. amount =  int. Parse(temp [c ]);
                         }
                        
                    }
                    
                    
                    
                }
                OutputBox. Text += Environment. NewLine;
   | 	 
 	  | code: | 	 		  
 
//-------------------------------------------------------------
 
TEXT FILE CONTAINS:
 
 
Site 1994 1995 1996 1997 1998 1999
 
Chedoke 102 89 144 66 102 92
 
Chicopee 135 122 101 162 193 182
 
Blue-Mtn. 178 124 175 201 162 205
 
Aspen 214 122 187 245 125 280
 
Whistler 200 150 180 215 149 301
 
 
//-------------------------------------------------------------
 
 
DISPLAYS:
 
 
Site    1994        1995    1996        1997    1998        1999    
 
Chedoke 102      89    144 66       102    92  
 
Chicopee        135     122  101       162    193 182      
 
Blue-Mtn.       178    124 175      201   162        205     
 
Aspen   214        122     187  245       125    280 
 
Whistler        200     150  180       215    149 301      
 
  | 	  
 
 
 
So it basically works, but i dont know why. I did the code from scratch, then i played around with it a lot to get it working and magically it all worked! I was happy, but now im curious as to why it works. I tried to run through it step by step but that takes to long and I got to start working on it again >.>
 
 
Mod edit:  Added syntax/code tags to make it readable. 
 
 
^ Thank you. - RealityFix.
 
 
 
- I think i made a big boo boo. Chart[*,*].amount seems to be be equal to my CityContainer[*].years.  Thats not good, lol I'm so bad at programming with datafiles xD | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		RealityFix
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Nov 08, 2009 4:40 pm    Post subject: Re: C Sharp help?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
					  | C#: | 	 		  
 
public void Average()
 
        {
 
            for (int rows = 1; rows <=5; rows++)
 
            {
 
                for (int c = 1; c <= 4; c++)
 
                {
 
                    CityContainer[rows].Average+=Chart[rows,c].amount ;
 
                    
 
                }
 
                CityContainer[rows].Average /= 6;
 
                
 
            }
 
  | 	  
 
 
I tried calculating the average as well. Didn't work out either. So yaaaa... Really need help with this irritating program.
 
 
Well I think the problem is the fact that the variable line isn't working as i hoped. It seems like the first row of years are being fed into Chart[].amount array. 
 
Anyone know how to fix this problem? Or at least I think thats the problem.
 
 
 
-HA! I got it working a little. Im on the verge of discovery before 9pm! no lack of sleep tonight ^_^ 
 
 
I will show the answer when im done. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		RealityFix
 
 
 
    
		 | 
		
		
			
				  Posted: Mon Nov 09, 2009 4:25 pm    Post subject: RE:C Sharp help?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| K well. Problem solved. To lazy to show answer, so can a mod close this thread? | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		rdrake
 
  
 
    
		 | 
		
		
			
				  Posted: Mon Nov 09, 2009 7:39 pm    Post subject: RE:C Sharp help?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| We generally don't close threads unless it's absolutely necessary. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		RealityFix
 
 
 
    
		 | 
		
		
			
				  Posted: Tue Nov 17, 2009 9:05 am    Post subject: RE:C Sharp help?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Ok then. I guess its not really neccesary. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |