Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

How to pass an array to a procedure

I need to pass parameters to a procedure.
What is the syntax for passing an array?

// Declare variables
int[] arrDealtCards = new int[2];
        int intHole1 = 5;
        int intHole2 = 7;
        int intFlop1 = 11;
        intFlop2 = 7;

        arrDealtCards[0] = intHole1;
        arrDealtCards[1] = intHole2;
        arrDealtCards[2] = intFlop1;

// Pass variables to the CheckForDup procedure
blnIsDup = CheckForDup(intFlop2, arrDealtCards, 3);  // line 81 generates the error

Error      2      The best overloaded method match for 'PreFlopPractice.CheckForDup(int, int, int)' has some invalid arguments      C:\Users\Admin\Documents\Visual Studio 2008\WebSites\NoLimitBusiness\PreFlopPractice.aspx.cs      81      20      C:\...\NoLimitBusiness\

 private bool CheckForDup(int pintDealtCard, arr[] parrDealtCards, int pintCtr)
    //Returns True if duplicate is found
   
    {
        bool blnIsDup = false;
        // This will loop until intFlop2 = one of the earlier cards
        int intCtr = 0;
        do
        {
            blnIsDup = (pintDealtCard == parrDealtCards[pintCtr]);
            intCtr++;
        }
        while (!blnIsDup);
         
        return blnIsDup;
    }

Thanks,

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

Thank you both for this workable solution.