c sharp

Environment.MachineName Property

If you want to know your Network Basic Input/Output System name, you should know about the property that returns the Name of the Network basic input-output system in C#.

Now, we will discuss that property in detail.

Environment.MachineName

This property is available in the Environment Class. It provides an information about the working environment like variables, methods used, and system related information in C#.

MachineName is a property in C# Environment class that is used to return the name of the Network basic input-output system. It returns the string.

This property can be applied in the .NET 2.0,2.1,3.0.3.1 and 6.7.

Syntax:
string Environment.MachineName

Example 1:

Return the system name using the previous property.

Explanation:

Line 01: We use the System library for using the Console.WriteLine() and the other statements in our code.

Line 03: We create a class named Linuxhint after.

Line 05: The main() method starts from here.

Line 09: Console.WriteLine(“Network Basic Input/Output System name is : “+Environment.MachineName);

Inside the main() method, we display the machine name using the MachineName.

Finally, the name returned is Check. So, the MachineName (Network Basic Input/Output System name) is Check.

Example 2:

Here, run on a local system. It returns the name of the MachineName.

using System;

class Linuxhint {

static public void Main()
{
//return the name of the machine(Network Basic Input/Output System name)

Console.WriteLine("Network Basic Input/Output System name is : "+Environment.MachineName);
 
}

}

Output:
The Network Basic Input/Output System name is: Sravan KKM.

Conclusion

In this C# tutorial, we discussed how to get the machine name using the MachineName property by running the C# program on the online compiler and personal system. This property is available in the Environment Class. It returns the name of the Network basic input-output system.

About the author

Gottumukkala Sravan Kumar

B tech-hon's in Information Technology; Known programming languages - Python, R , PHP MySQL; Published 500+ articles on computer science domain