Reputation: 105
I have an ObservableCollection:
public ObservableCollection<NurDeviceWatcherInfo> KnownDevices = new ObservableCollection<NurDeviceWatcherInfo>();
NurDeviceWatcherInfo
has these string properties: Address, ConnState, Info, Name, Spec, SpecStr, Tag, TransportType.
What I am trying to use is:
NurDeviceWatcherInfo device = from NurDeviceWatcherInfo in KnownDevices
where NurDeviceWatcherInfo.Name.Contains("NUR")
select new NurDeviceWatcherInfo();
For which I receive the following error:
Severity Code Description Project File Line Suppression State Error CS0266 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'NurApiDotNet.UWP.NurDeviceWatcherInfo'. An explicit conversion exists (are you missing a cast?)
What would be the correct syntax?
Upvotes: 2
Views: 263
Reputation: 105
I solved it using :
device = KnownDevices.Where(x => x.Name.Contains("NUR")).FirstOrDefault();
Upvotes: 1