The source code to get the Computer System User Name using Environment class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
string username = "";
username = Environment.UserName;
Console.WriteLine("Computer System User Name: " +username);
}
}
Output:
Computer System User Name: Nidhi
Press any key to continue . . .
Program:
The source code to get the Computer System User Name using Environment class is given below. The given program is compiled and executed successfully.
Output: