I would like to know if it is possible to read a certain string of n-length, from x character to y character without having to split it into smaller pieces.
I have the following string, for a path in AD CN=someName,OU=someGroup,OU=groups,DC=some,DC=domain,DC=com
, and I would like to be able to just read the someName
part of it, without splitting by =
or ,
first. How do I achieve that?
Reason is, that I do not have to do group comparison as I am doing it right now:
SearchResult t1 = search.FindOne();
foreach (string s in t1.Properties["memberof"])
{
foreach (string g in groups)
{
if (s.ToLower().Contains(g.ToLower()))
{
// do something
}
}
}
I would rather make the if clause to equals, but I do not want to always split the above path/groups into an array twice. How do I do that?