Mono Class Library: System.Environment Overview | Members

System.Environment.MachineName Property

ReadOnly property for getting the machine name of the computer.

public static string MachineName { get; }

Value

The machine name of the computer the application is running on.

Remarks

The information in the Environment.MachineName is dependent on the underlying operating system.
  • On Linux, this returns the value of the HOSTNAME environment variable.
  • On Windows, this returns the NETBIOS machine name of the computer.

C# Example

using System;

class SystemDemo
{
	public static void Main(string[] args)
	{
		Console.WriteLine(Environment.MachineName);
	}
}
  
Executing this program on a linux machine returns a name like "machinename.example.com", while on Windows, it'll show a name like "MACHINENAME".

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0