Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
WebcamCtrl.StartCapture();
foreach (EncoderDevice device in _vidDevices.Where(device => device.Name == "Microsoft LifeCam Rear"))
{
    VideoDevicesComboBox.SelectedItem = device;
    break;
}
Posted
Updated 11-Dec-14 23:02pm
v2
Comments
Pheonyx 12-Dec-14 4:37am    
What does "breakdown" mean? Do you get an exception? What behaviour are you expecting?
What debugging steps have you tried?

1 solution

Try this
C#
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).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900