C# Accessing management objects in ManagementObjectCollection
ManagementObjectCollection implements IEnumerable or ICollection, so either you must iterate it via IEnumerable (ie foreach) or CopyTo an array via ICollection.
However since it supports IEnumerable you can use Linq :
ManagementObject mo = queryCollection.OfType<ManagementObject>().FirstOrDefault()
OfType<ManagementObject>
is required because ManagementObjectCollection supports IEnumerable but not IEnumerable of T.
You can not directly call linq from ManagementObjectCollection (nor an integer indexer). You have to cast it to IEnumerable first:
var queryCollection = from ManagementObject x in query.Get()
select x;
var manObj = queryCollection.FirstOrDefault();