Syntax:
IDictionary Environment.GetEnvironmentVariables();
Parameter(s):
This method returns the object of IDictionary class.
Return value:
This method returns an array of strings that contains the name of logical drives of the computer system.
To use IDictionary class we need to include System.Collections namespace.
Exception(s):
- System.Security.SecurityException
- System.OutOfMemoryException
-
Program:
The source code to get the environment variables using Environment class is given below. The given program is compiled and executed successfully.
Output: