Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
static string diziKarsilastir(ArrayList a, ArrayList b)
        {
            string[] dizi = new string[4];
            for(int i = 0; i<4; i++)
            {
                if(a[i].ToString() == b[i].ToString())
                {
                    dizi[i] = "true";
                }
                else
                {
                    dizi[i] = "false";
                }
            }
            
            return dizi[];
       
        }


What I have tried:

I want to return the dizi array, but I get an error. (Error CS0443 Syntax error; value expected) When I use for loop ; (
Error CS0161 'Form1.diziKarsilastir(ArrayList, ArrayList)': not all code paths return a value)
Posted
Updated 5-Nov-16 2:14am

dizi is a string[] so your function should be :
C#
static string[] diziKarsilastir(ArrayList a, ArrayList b)
{
...
}


EDIT:
You need to remove the square brackets from the return statement:
C#
return dizi;
 
Share this answer
 
v2
Comments
Midi_Mick 5-Nov-16 8:27am    
Also, your return statement will error - don't include the square brackets. C# doesn't like that. Improving Mehdi's answer to include that.
Member 12833990 5-Nov-16 8:53am    
return dizi; is okey ! :)
Member 12833990 5-Nov-16 8:52am    
Thank you.. string[] is worked ! :)
You probably have to have the receipt.

Seriously though...

Your method is likely to throw an exception if either of the parameters contain fewer than four elements, or either is null. Your method would never pass a code review, or even pass a reasonably complete unit test.

Medhi Gholam's solution is the answer you're looking for, but I would also refactor the method to be more robust.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900