3
I came across a C# scenario that I didn’t quite understand. I was studying and I saw a code piece with a generic type that has the reserved word in
for that guy.
What would be the purpose of using this in
in the Generic Type declaration?
Code example:
public interface IHandler<in T> where T : Message
{
void Handle(T message);
}
This article from Microsoft I think explains well what the
in
: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-generic-modifier– João Martins
From what little I’ve read, it seems similar to
super
java– Jefferson Quesado
I guess that answers, doesn’t it? https://answall.com/q/32880/101. If not, give the context where you saw it.
– Maniero
Thanks @Joãomartins and @Maniero!!
– Pedro Paulo