I have problem i want to use bool function to create searching algorithm this is my code
private bool IsEqual(int data1, int[] arr2){
bool find=false;
foreach(int data2 in arr2){
if(data1==data2){
find=true;
break;
}
}
return find;
}
and this is i call the function
int data1=2;
int[] arr={1,2,3,4,5};
if(IsEqual(data1, arr)){
console.writeline("Find in index");
}
how can i get the index of the array if the number is find?
Note:
I must use bool function
I can't add parameter in bool function
i can't add keyword in parameter like ref int data1
only change bool function
I can't add other function
Array.IndexOfIsEqualmethod a black box. You can only returnbooland you aren't allowed to use anoutparameter. What are you allowed to do?