Cannot convert expression type to return type

I have the following method that works:

public Option<IAppSettings> GetFirst<T>() where T : IAppSettings
{
  return _sources.Where(x=>x.GetType() == typeof(T)).FirstOption();
}

List<IAppSettings> _sources;

But I want to change the signature to:

public Option<T> GetFirst<T>() where T : IAppSettings

Please note that I return the general TinsteadIAppSettings

I get an error (truncated types):

Cannot convert expression type Option<IAppSettings>toOption<T>

I know that this has anything to do with generics, but, admittedly, suck them ... I tried different means in, out, interface, delegate... but none worked as a method for non-general of the class using a variable instance.

Is it possible?

Updated thoughts

Option? , , Option<in T>? , , Scala Option Option[+A] Option, , ... ,

Option scalesque

+4
2

.OfType() .FirstOption().

0

All Articles