What is the use of System.Environment class in C#.NET?- The System.Environment class can be used to retrieve information like:
a. Command-line arguments.
b. The exit code.
c. Environment variable settings.
d. Contents of the call stack.
e. Time since last system boot.
f. The version of the common language runtime.
- It provides the information about the current environment and platform.
- This class is mostly used to retrieve environment variable settings, version of the common language runtime etc.
- System.Environment class cannot be inherited.
- Using System.Environment.OS.Version.ToString(), it will return your current operating system.
- Using System.Environment.MachineName, it will return your current machine name.
- Using System.Environment.CurrentDirectory, it will return your current working directory.
- Using System.Environment.UserName, it will return your current user name.