Skip to content

Instantly share code, notes, and snippets.

@zhangr4
Last active March 5, 2025 10:04
Show Gist options
  • Save zhangr4/b0c8ebdbf9c5757e04699a9922229109 to your computer and use it in GitHub Desktop.
Save zhangr4/b0c8ebdbf9c5757e04699a9922229109 to your computer and use it in GitHub Desktop.
csharp snippets
Console.WriteLine();
// <-- Keep this information secure! -->
Console.WriteLine("UserName: {0}", Environment.UserName);
//this one can get domain and user name
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Console.WriteLine();
Console.WriteLine(userName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment