c# - Find first free element -


i looking query return first number not available in list

int[] list = new int[] { 1,4,2,5,6,7 }; 

for above example expect have result 3.

perhaps this:

int result = enumerable.range(1, list.length)                        .where(i => !list.contains(i))                        .firstordefault(); 

this return 0 if list contains integers 1 n.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -