LINQ "MaxOrDefault"?
How about:
int new_id = 0;
if (C_Movement.list.Any())
new_id = C_Movement.list.Max(x => x.id) + 1;
DefaultIfEmpty method should help:
int new_id = C_Movement.list.Select(x => x.id).DefaultIfEmpty(-1).Max()+1;
int new_id = C_Movement.list.Max(x => (int?)x.id).GetValueOrDefault(-1) + 1;
where GetValueOrDefault
is a method of Nullable<T>
.