Try this
var devices = _vidDevices.Where(device => device.Name == "Microsoft LifeCam Rear");
if (devices != null)
{
foreach (EncoderDevice device in devices)
{
VideoDevicesComboBox.SelectedItem = device;
break;
}
}
Then analyze what the variable
devices
contains.
For a foreach loop to work, the variable
devices
should be a list, even if it is empty (length = 0).