In the following method, how can I prevent the contents of my array from being modified accidentally or otherwise?
Can it be done without changing the array to another type, such as a list?
public static int LinearSearch(int[] myArray, int target)
{
int idx = -1;
for (int i = 0; i < myArray.Length; i++)
{
if (myArray[i] == target) { idx = i; break; }
}
return idx;
}