0

I'm going through a .NET Core tutorial and I'm seeing a lot things like ILogger<HomeController> which to me (since all I recognize them as types) looks a lot like typecasting.

The only conclusion I can come up with is if I wrote say ILogger(HomeController) I'm telling it to cast it to say type HomeController (giving me an error because I cannot) while ILogger<HomeController> is just telling the controller 'which' type of ILogger it is.

However, I am having trouble finding any documentation so my conclusions can be totally wrong.......

Thanks for your help!

GSerg
  • 76,472
  • 17
  • 159
  • 346
  • No, `<>` is used for **generic types**. `ILogger` is a type itself. `()` is used to **cast**: that can be to a generic type, but also to a primitive type or a non-generic one – Willem Van Onsem Apr 15 '17 at 17:06
  • It would be a lot easier to answer if you gave a concrete piece of code – Ofir Winegarten Apr 15 '17 at 17:08
  • Thank you, this is a duplicate. This is the first I heard of generics in C#, so I didn't know exactly how to ask the question! – maestroanth Apr 16 '17 at 01:22

0 Answers0