I' having tough time with handling generics in C#, following is the code snippet that i'm using
public delegate void SyncEventDelegate<TEntity>(TEntity entity, SyncInfo requestInfo);
i need to add this delegate to a Dictionary
private Dictionary<Type, SyncEventDelegate<ISynchronizeableEntity>> _delegateCollection;
the method that passes the the delegate to register has the following signature.
public void Register<TEntity>( SyncEventDelegate<ISynchronizeableEntity> syncEventDelegate) where TEntity : ISynchronizeableEntity
it's working fine for the moment , but I have a doubt if i change the register method signature to the following format , i get a compiler error.
public void Register<TEntity>( SyncEventDelegate<TEntity> syncEventDelegate) where TEntity : ISynchronizeableEntity
I thought it should work since TEntity is derived from ISynchronizeableEntity, but it doesn't.
I really appreciate if someone can explain this.
thanks in advance.