best Overloaded match for method ...

This is a discussion on best Overloaded match for method ... within the C# Programming forums, part of the General Programming Boards category; When I compile it tells me best overloaded match for method AESEncryption.shiftrow(byte[], byte); I am still new to C sharp ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    best Overloaded match for method ...

    When I compile it tells me best overloaded match for method AESEncryption.shiftrow(byte[], byte);

    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 2
    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);
        }
    I need help with code 2

  2. #2
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    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.
    Last edited by stumon; 11-05-2009 at 10:37 PM.
    The keyboard is the standard device used to cause computer errors!

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    14
    well i tried doing it with nothing and it still doesn't work

  4. #4
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    Quote Originally Posted by deathkosui View Post
    well i tried doing it with nothing and it still doesn't work

    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!

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    14
    yeah but how do i pass a byte array through a method ?

  6. #6
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    Quote Originally Posted by deathkosui View Post
    yeah but how do i pass a byte array through a method ?

    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!

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    14
    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);
    ?

  8. #8
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    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!

  9. #9
    Registered User
    Join Date
    Nov 2009
    Posts
    14
    oh i get it alright thanks for the help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 11:53 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. overloaded >> operator issue...
    By soulredemption in forum C++ Programming
    Replies: 2
    Last Post: 10-17-2005, 11:53 PM
  4. 2 array match
    By ajastru2000 in forum C++ Programming
    Replies: 5
    Last Post: 07-18-2003, 08:58 AM
  5. overloaded on overloads
    By emceedee in forum C++ Programming
    Replies: 1
    Last Post: 03-31-2003, 02:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21