C# Finding the Operating System Username

In the C# programming language, the UserName property of the Environment class is used to find the active user name in the current operating system.

An example of this usage is given below.

namespace ConsoleApplicationTest
{
    class Program {

        static void Main(string[] args) {

            string uName = System.Environment.UserName;

            Console.WriteLine(uName);
            Console.ReadLine();

        }
    }
}



You May Interest

C# Non-Restart Check If Application is Open

C# Finding the Path to My Documents Folder

C# Finding the Path to the Windows AppData Folder

C# How To Find The Average Of 10 Numbers Using A While Loop

C# Finding the Sine of an Angle