this post was submitted on 28 Nov 2023
555 points (97.9% liked)

Programmer Humor

32000 readers
1744 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 5 points 9 months ago (1 children)

I have used typeof(T) inside the generic class, so fx a function inside the class Pie where T can be refered. But out of context, if you were to call typeof(T) inside Program.cs's main function, it would not work.

[โ€“] [email protected] 3 points 9 months ago

Yeah, but to do that you'd need an instantiated instance of the Pie class, which would answer in the context of the generic type parameter, not the whole Pie class.

This is too funny. Everyone here, me included, is profoundly overthinking this, lol.