S
shapper
Hello,
I have been coding a lot with Linq but I got stopped by something
unexpected.
I have a IList<String> that contains values from 1 to 10. An example:
IList<String> roles = (new String[] { "1", "2", "4",
"10" }).ToList();
String role = "5";
1) roles never have repeated values.
2) roles have only one value between 4 to 7. Example:
roles can contain "1", "2" "5" and "10"
but it can't contain "1" "2", "4", "7" and "10"
Basically role has a value that should update the value in roles
between 4 and 7.
So in the example posted: "5" will be added to roles and "4" will be
removed.
I was trying to use something like:
roles.Remove(s => Int32.Parse(s) >= 4 && Int32.Parse(s) <= 7);
roles.Add(role);
But Remove does not allow this ...
How can I do this?
Thanks,
Miiguel
I have been coding a lot with Linq but I got stopped by something
unexpected.
I have a IList<String> that contains values from 1 to 10. An example:
IList<String> roles = (new String[] { "1", "2", "4",
"10" }).ToList();
String role = "5";
1) roles never have repeated values.
2) roles have only one value between 4 to 7. Example:
roles can contain "1", "2" "5" and "10"
but it can't contain "1" "2", "4", "7" and "10"
Basically role has a value that should update the value in roles
between 4 and 7.
So in the example posted: "5" will be added to roles and "4" will be
removed.
I was trying to use something like:
roles.Remove(s => Int32.Parse(s) >= 4 && Int32.Parse(s) <= 7);
roles.Add(role);
But Remove does not allow this ...
How can I do this?
Thanks,
Miiguel