Try the following code:
const string queryString = "SELECT SerialNumber FROM Win32_OperatingSystem";
string productId = (from ManagementObject managementObject in new ManagementObjectSearcher(queryString).Get()
from PropertyData propertyData in managementObject.Properties
where propertyData.Name == "SerialNumber"
select (string)propertyData.Value).FirstOrDefault();
Console.WriteLine(productId);