If I understand correctly, you want to find the first positive integer number that is not in the list. (since you’re using “the” first number, I assume you don’t need an array of numbers with all holes.)
The way you do this is (assuming the array is sorted like in your examples) is by simply starting with zero and adding one until the array doesn’t contain the number:
int[] arrayWithNumbers = new int[] {0, 1, 3, 4, 9, 10, 15};
int i = 0;
while (arrayWithNumbers.Contains(i)) //check if number already exists in array
{
i++; //increment by 1
}
Console.WriteLine(i);
4
solved How to find the first positive integer number that is not in the list [closed]