Ingve
asked on
Loop through IDictionary
I would like to list the content of the dictionary in the code in this post, but I can't seem to get it right. Could someone help me?
/// <summary>
/// Get the machine level information.
/// </summary>
/// <returns></returns>
public static IDictionary GetMachineInfo()
{
// Get all the machine info.
IDictionary machineInfo = new SortedDictionary<string, object>();
machineInfo["Machine Name"] = Environment.MachineName;
machineInfo["Domain"] = Environment.UserDomainName;
machineInfo["User Name"] = Environment.UserName;
machineInfo["CommandLine"] = Environment.CommandLine;
machineInfo["ProcessorCount"] = Environment.ProcessorCount;
machineInfo["OS Version Platform"] = Environment.OSVersion.Platform.ToString();
machineInfo["OS Version ServicePack"] = Environment.OSVersion.ServicePack;
machineInfo["OS Version Version"] = Environment.OSVersion.Version.ToString();
machineInfo["OS Version VersionString"] = Environment.OSVersion.VersionString;
machineInfo["System Directory"] = Environment.SystemDirectory;
machineInfo["Memory"] = Environment.WorkingSet.ToString();
machineInfo["Version"] = Environment.Version.ToString();
machineInfo["Current Directory"] = Environment.CurrentDirectory;
return machineInfo;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
foreach (string key in machineInfo.Keys)
{
string value = machineInfo[key];
}