Skip to content
Discussion options

You must be logged in to vote

You need to add the class constraint, since covariant type parameters don't work with structs:

    public class SingleHashFunctionList<T> : IHashFunctionList  
        where T : class, IHashFunction
    {
        private readonly IReadOnlyList<T> _hashFunctions;

        public SingleHashFunctionList()
        {
            // Skip init work of '_hashFunctions'
            HashFunctions = _hashFunctions;
        }

        public IReadOnlyList<IHashFunction> HashFunctions { get; }
    }

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@LeaFrock
Comment options

@yaakov-h
Comment options

Answer selected by LeaFrock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants