Implement C# generic class to refactor classes,and I face the problem like this: C# generic class implement error Error CS0428 Cannot convert method group 'InitConfig' to non-delegate type 'T'. Did you intend to invoke the method?
Error CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
public class RedisDatabaseService<T> : IRedisDatabase<T> where T : class,IConfig
{
public Lazy<T> lazyConfig { get; } = new Lazy<T>(()=> InitConfig);
public T InitConfig()
{
throw new NotImplementedException();
}
}
public interface IRedisDatabase<T> where T : class
{
T InitConfig();
}
after I add brace() , but still have some problem,
"Cannot access non-static method..." ,so I can not implement all interface members.. How to modify the code to avoid the errors? Thanks a lot!
new Lazy<T>(()=> InitConfig());() =>?