System information C# Exercise - C# Programming Course

 Exercise

System information

 Objetive

Create a program that shows specific system details, including the computer name, domain name, and the username of the user who is currently logged in.

 Example Code

// Import necessary namespaces for working with system information
using System;

class SystemInformation
{
    // Main method where the program execution starts
    static void Main()
    {
        // Display the name of the computer
        Console.WriteLine("Computer Name: " + Environment.MachineName);

        // Display the domain name (or "Workgroup" if not part of a domain)
        Console.WriteLine("Domain Name: " + Environment.UserDomainName);

        // Display the username of the currently logged-in user
        Console.WriteLine("User Name: " + Environment.UserName);
    }
}

Juan A. Ripoll - Programming Tutorials and Courses © 2025 All rights reserved.  Legal Conditions.