By using Select on a comparison, you will only get a bool result. You need to use the comparison in a
Where
statement.
Also, using
ToList
inside a Linq query, the
ToList
will be called
for each comparison which is highly inefficient. So you wouild be better off using a temporary variable that contains the list so that it is only called once.
With that in mind, I would suggest using something like:
Dim result = ByteDic.Where(Function(x) Not used.Any(Function(y) y.Key.Equals(x.Key))).Max(Function(x) x.Value)
or
Dim result = ByteDic.Where(Function(x) Not used.Keys.Contains(x.Key)).Max(Function(x) x.Value)
or
Dim result = ByteDic.Where(Function(x) Not used.ContainsKey(x.Key)).Max(Function(x) x.Value)