<p>I would like to remove the domain/computer information from a login id in C#.  So, I would like to make either "Domain\me" or "Domain\me" just "me".  I could always check for the existence of either, and use that as the index to start the substring...but I am looking for something more elegant and compact.</p>

<p>Worse case scenario:</p>

<pre><code>int startIndex = 0;
int indexOfSlashesSingle = ResourceLoginName.IndexOf("\");
int indexOfSlashesDouble = ResourceLoginName.IndexOf("\\");
if (indexOfSlashesSingle != -1)
    startIndex = indexOfSlashesSingle;
else
    startIndex = indexOfSlashesDouble;
string shortName = ResourceLoginName.Substring(startIndex, ResourceLoginName.Length-1);
</code></pre>

I always do it this way:
```
```
string[] domainuser;
    string Auth_User = Request.ServerVariables["AUTH_USER"].ToString().ToLower(); 
    domainuser = Auth_User.Split('\\');
```
```
Now you can look at domainuser.Length to see how many parts are there and domainuser[0] for the domain and domainuser[1] for the username.