![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 10
| best Overloaded match for method ... I am still new to C sharp so can somebody tell me? Code: public static void shiftRow(byte[] state, byte nbr)
{
int i;
int j;
byte tmp;
// each iteration shifts the row to the left by 1
for (i = 0; i < nbr; i++)
{
tmp = state[0];
for (j = 0; j < 3; j++)
state[j] = state[j + 1];
state[3] = tmp;
}
}
Code: public static void shiftRows(ref byte state)
{
int i;
// iterate over the 4 rows and call shiftRow() with that row
for (i = 0; i < 4; i++)
shiftRow(Convert.ToInt16(state + i * 4), i);
}
|
| deathkosui is offline | |
| | #2 |
| eh ya hoser, got a beer? Join Date: Feb 2003
Posts: 287
| You're trying to pass variables with int class data types to a Method that takes an array of bytes as the first argument and a byte data type for the second argument. You need to figure out what you want to use, bytes or ints. Then make sure you want to send an array of them or just 1 element when you call the Method. Code: shiftRow(Convert.ToInt16(state + i * 4), i); // Why have the Convert.ToInt16??? You're changing its data type, and 'i' is an integer to begin with.
__________________ The keyboard is the standard device used to cause computer errors! Last edited by stumon; 11-05-2009 at 10:37 PM. |
| stumon is offline | |
| | #3 |
| Registered User Join Date: Nov 2009
Posts: 10
| well i tried doing it with nothing and it still doesn't work |
| deathkosui is offline | |
| | #4 |
| eh ya hoser, got a beer? Join Date: Feb 2003
Posts: 287
| You tried calling the Method without any arguments? Well that obviously wouldn't work unless you overloaded the Method with one that has no arguments. You just need to make sure that the Method gets the data types it wants, and the same number of them. Figure out what you want to pass. If its just 1 element of an array, then make the Method take 1 byte data type variable, otherwise, you will need to pass the whole array to that method if it asks for an array of bytes.
__________________ The keyboard is the standard device used to cause computer errors! |
| stumon is offline | |
| | #5 |
| Registered User Join Date: Nov 2009
Posts: 10
| yeah but how do i pass a byte array through a method ? |
| deathkosui is offline | |
| | #6 |
| eh ya hoser, got a beer? Join Date: Feb 2003
Posts: 287
| Code:
public void MyMethod(byte[] hey)
{
// use hey[1] or hey[whatever] for something....
}
public void MyMethod2()
{
byte[] blah = new byte[10];
MyMethod(blah);
}
__________________ The keyboard is the standard device used to cause computer errors! |
| stumon is offline | |
| | #7 |
| Registered User Join Date: Nov 2009
Posts: 10
| yeah okay that gives rid of the error but i want blah to stand for a value (state+4*i) is it possible to put int k = state+4*1; byte[] blah = { k }; and add shiftRow(blah[1], i); ? |
| deathkosui is offline | |
| | #8 |
| eh ya hoser, got a beer? Join Date: Feb 2003
Posts: 287
| That all depends on what data type state is. In both examples of your code, you are passing something into either an array of byte's called state or in the second example its just a single byte variable called state. Somewhere you are going to have to cast something to make the data types match... and casting the name of an array will give you a runtime error.
__________________ The keyboard is the standard device used to cause computer errors! |
| stumon is offline | |
| | #9 |
| Registered User Join Date: Nov 2009
Posts: 10
| oh i get it alright thanks for the help |
| deathkosui is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| No Match For Operator+ ??????? | Paul22000 | C++ Programming | 24 | 05-14-2008 10:53 AM |
| We Got _DEBUG Errors | Tonto | Windows Programming | 5 | 12-22-2006 05:45 PM |
| overloaded >> operator issue... | soulredemption | C++ Programming | 2 | 10-17-2005 10:53 PM |
| 2 array match | ajastru2000 | C++ Programming | 5 | 07-18-2003 07:58 AM |
| overloaded on overloads | emceedee | C++ Programming | 1 | 03-31-2003 02:14 AM |