我有此下面的代碼,這將取的loggedIn用戶ID的IndexOf功能
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
//networkID=User.
string strName = p.Identity.Name;
int start;
start = strName.IndexOf("\") + 1 ;
strName = strName.Substring(start, strName.Length - start);
但開始= strName.IndexOf( 「\」)+ 1;拋出錯誤說不斷換行換行。我登錄的用戶名是domainName \ username,我只想使用用戶名。請幫助