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# Example of Sum of Even Numbers from 1 to 100

C# Finding the Desktop Path

C# Finding Cosine of an Angle

C# Finding the Path to the Windows Fonts Folder

C# Finding the Computer Name