New Posts  All Forums:Forum Nav:

C# Help again

post #1 of 6
Thread Starter 
Hey guys I have created a array with 20 labels as follows
Code:
public void arrayGameProp()
        {
Label[,] arrayGame = new Label[4, 5];
            arrayGame[00, 00] = lbl1;
            arrayGame [01,01] = lbl2;
            arrayGame [02,02] = lbl3; 
            arrayGame [03,03] = lbl4;
            arrayGame [04,04] = lbl5;
            arrayGame [10,10] = lbl6;
            arrayGame [11,11] = lbl7;
            arrayGame [12,12] = lbl8;
            arrayGame [13,13] = lbl9;
            arrayGame [14,14] = lbl10;
            arrayGame [20,20] = lbl11;
            arrayGame [21,21] = lbl12;
            arrayGame [22,22] = lbl13;
            arrayGame [23,23] = lbl14;
            arrayGame [24,24] = lbl15;
            arrayGame [30,30] = lbl16;
            arrayGame [31,31] = lbl17;
            arrayGame [32,32] = lbl18;
            arrayGame [33,33] = lbl19;
            arrayGame [34,34] = lbl20;
}

Now i want to take 5 places in that array and set them a static value.
so I was trying to like this.
====================
public void winingBoxes()

winingBoxes = arrayGameProp (00,00);

This is the error i am getting

Error 1 No overload for method 'arrayGameProp' takes 2 arguments

not to sure where i have gone wrong any help please?

i will be working on this in the meantime so I will update it if i figure it out.
Edited by ipv89 - 4/8/13 at 12:31am
Mid range build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 3570k P8Z77-V ASUS ROG RX480 Corsair 8GB 2x 2GB + kingston hyperx 16gb 
Hard DriveOptical DriveCoolingOS
Samsung Evo SSD 500gb none corsair H80 windows 7 64 
MonitorPowerCaseMouse
Samsung s22b360 corsair tx 750 m NZXT phantom 410 (GM) logitech G400 
  hide details  
Reply
Mid range build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 3570k P8Z77-V ASUS ROG RX480 Corsair 8GB 2x 2GB + kingston hyperx 16gb 
Hard DriveOptical DriveCoolingOS
Samsung Evo SSD 500gb none corsair H80 windows 7 64 
MonitorPowerCaseMouse
Samsung s22b360 corsair tx 750 m NZXT phantom 410 (GM) logitech G400 
  hide details  
Reply
post #2 of 6
The arrayGameProp method you have there does not takes in any parameters.

public void arrayGameProp( ) ......

is it meant to be like ?
public void arrayGameProp( int x, int y) ......

Not sure of the other parts.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS - P8Z68-V/GEN3 GTX 770 DDR3 - 8G 
Hard DriveOSMonitorPower
WD Green Win 7 x64 Dell ST2320L Corsair 750TX 
CaseMouse
Coolermaster 310 Logitech G502 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS - P8Z68-V/GEN3 GTX 770 DDR3 - 8G 
Hard DriveOSMonitorPower
WD Green Win 7 x64 Dell ST2320L Corsair 750TX 
CaseMouse
Coolermaster 310 Logitech G502 
  hide details  
Reply
post #3 of 6
I think you mean to be calling something like this:
winingBoxes = arrayGame[00,00];

You don't want to be calling arrayGameProp again, because it will re-initialize your array every time you call it.
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
post #4 of 6
Its kind of hard to tell what exactly you are trying to do here, if you are trying to assign the values in the array you are going to need to set them in the function they were called in because you dont return anything from the function.

For example
Code:

public Label[,] arrayGameProp()
        {
Label[,] arrayGame = new Label[4, 5];
            arrayGame[00, 00] = lbl1;
            arrayGame [01,01] = lbl2;
            arrayGame [02,02] = lbl3; 
            arrayGame [03,03] = lbl4;
            arrayGame [04,04] = lbl5;
            arrayGame [10,10] = lbl6;
            arrayGame [11,11] = lbl7;
            arrayGame [12,12] = lbl8;
            arrayGame [13,13] = lbl9;
            arrayGame [14,14] = lbl10;
            arrayGame [20,20] = lbl11;
            arrayGame [21,21] = lbl12;
            arrayGame [22,22] = lbl13;
            arrayGame [23,23] = lbl14;
            arrayGame [24,24] = lbl15;
            arrayGame [30,30] = lbl16;
            arrayGame [31,31] = lbl17;
            arrayGame [32,32] = lbl18;
            arrayGame [33,33] = lbl19;
            arrayGame [34,34] = lbl20;

return arrayGame;
}
Then from your main function or wherever you are working, you would need to get this object.
Code:
//Note if this is a console application your 
//functions will need to be static as well

static void Main()
{
Label[,] myReturnedArray = arrayGameProp();

//Now set the winning indices

myReturnedArray[0,0] = winningLbl1;
myReturnedArray[0,1] = winningLbl2;

//Etc

}

The alternative solution is to just set them in your function, but this doesnt really serve a purpose without anything returned?
Code:

public void arrayGameProp()
        {
Label[,] arrayGame = new Label[4, 5];
            arrayGame[00, 00] = lbl1;
            arrayGame [01,01] = lbl2;
            arrayGame [02,02] = lbl3; 
            arrayGame [03,03] = lbl4;
            arrayGame [04,04] = lbl5;
            arrayGame [10,10] = lbl6;
            arrayGame [11,11] = lbl7;
            arrayGame [12,12] = lbl8;
            arrayGame [13,13] = lbl9;
            arrayGame [14,14] = lbl10;
            arrayGame [20,20] = lbl11;
            arrayGame [21,21] = lbl12;
            arrayGame [22,22] = lbl13;
            arrayGame [23,23] = lbl14;
            arrayGame [24,24] = lbl15;
            arrayGame [30,30] = lbl16;
            arrayGame [31,31] = lbl17;
            arrayGame [32,32] = lbl18;
            arrayGame [33,33] = lbl19;
            arrayGame [34,34] = lbl20;


            arrayGame[0,0] = winningLbl1;
            arrayGame[0,1] = winningLbl2;
}

Anyways I hope this helps you get something at least.
Edited by mykah89 - 4/8/13 at 8:06am
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
I5 760 GA-H55N GTX 470 PNY Optima 8GB 
Hard DriveMonitorPowerCase
Spinpoint F4 LG227WTG sg07 PSU Sugo sg07 
Mouse
CM Sentinel 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
I5 760 GA-H55N GTX 470 PNY Optima 8GB 
Hard DriveMonitorPowerCase
Spinpoint F4 LG227WTG sg07 PSU Sugo sg07 
Mouse
CM Sentinel 
  hide details  
Reply
post #5 of 6
Thread Starter 
sorry more information would have helped basically I am trying to create a grid of labels and have a certain amount of them set to have a different property. So I thought i would use a multidimensional array 1 dimension would be the labels with no value and the 2nd dimension would be the labels with the set values or am i allready wrong rolleyes.gif
Mid range build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 3570k P8Z77-V ASUS ROG RX480 Corsair 8GB 2x 2GB + kingston hyperx 16gb 
Hard DriveOptical DriveCoolingOS
Samsung Evo SSD 500gb none corsair H80 windows 7 64 
MonitorPowerCaseMouse
Samsung s22b360 corsair tx 750 m NZXT phantom 410 (GM) logitech G400 
  hide details  
Reply
Mid range build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 3570k P8Z77-V ASUS ROG RX480 Corsair 8GB 2x 2GB + kingston hyperx 16gb 
Hard DriveOptical DriveCoolingOS
Samsung Evo SSD 500gb none corsair H80 windows 7 64 
MonitorPowerCaseMouse
Samsung s22b360 corsair tx 750 m NZXT phantom 410 (GM) logitech G400 
  hide details  
Reply
post #6 of 6
Quote:
Originally Posted by ipv89 View Post

sorry more information would have helped basically I am trying to create a grid of labels and have a certain amount of them set to have a different property. So I thought i would use a multidimensional array 1 dimension would be the labels with no value and the 2nd dimension would be the labels with the set values or am i allready wrong rolleyes.gif

I think you're confused as of what multidimensional arrays are.

You can't use the different dimensions for different things. A 2D array is essentially a table. What you're saying is "In a table, I will use the rows for empty labels, and the colums for labels with values". Yes, but rows and colums in a table are not separate things, they intersect. The cells are the only thing in a table that you can use.

Now, if you're really making a grid, then you're almost on the right path.
In your 2D array, the first index identifier ( [ x, y] ) is the index of the column, the second ( [x, y ]) is the index of the row.

So if you want to set a value for the label that is on the second row in the third colum of your grid, you should do
Code:
my2Darray[3, 2] = myValue;
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming