Hi, I had a code for getting the hdd id written in vb.net
Now I need to re-write the code into c#. I have converted the vb.net code to c# but it is not compiling.
Below is the vb.net code
Dim hdCollection As ArrayList = New ArrayList()
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each wmi_HD As ManagementObject In searcher.Get()
Dim hd As HardDrive = New HardDrive()
hd.Model = wmi_HD("Model").ToString()
hd.Type = wmi_HD("InterfaceType").ToString()
hdCollection.Add(hd)
Next wmi_HD
here is the converted C# code:
ArrayList hdCollection = new ArrayList();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject wmi_HD in searcher.Get())
{
HardDrive hd = new HardDrive();
hd.Model = wmi_HD("Model").ToString();
hd.Type = wmi_HD("InterfaceType").ToString();
hdCollection.Add(hd);
}
Following is the error I am getting when compiling the c# code:
'wmi_HD' is a 'variable' but is used like a 'method'
Please help!