In .NET 4.5 Environment.GetEnvironmentVariables() returns the environment variables as a non-generic Collections.IDictionary.
Is there any way to get the environment variables in F# as a generic collection?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure whether .NET has any method that returns environment variables as a typed generic collection (the
GetEnvironmentVariablesmethod has been there since .NET 1.1 and so it is not generic). If you want to convert the result to a generic dictionary yourself, you can do something like this:This first converts the result to a sequence of
DictionaryEntryelements, then extracts key and value and casts them to a string and then buildsIDictionary<string, string>using built-indictfunction.