I have a variable which holds domain name and username such [DOMAIN]/[User]. When i use this variable in a linq query lookup, it does not find the user because it replaces a single backslash with a double backslash.
For example:
UPDATED
List<string> lstUsersToRemove = new List<string>() {"TEST\acuba","TEST\test2", "TEST\test3" };
foreach(string userName in lstUsersToRemove)
{
var user = listUsers.SingleOrDefault(x => x.UserName == userName);
if(user != null)
listUsers.Remove(user);
}
user is always null because it looks to match with the userName that has double backslash. It looks for "TEST\acuba" or "TEST\test2". I tested it when running it by manually removing the second backslash and was able to find the correct user.
Is there a way to correct this or an alternative way of doing the lookup without it failing because of the backslash?
Thanks in advance for your help.