Why is typeof needed?

后端 未结 6 1385
独厮守ぢ
独厮守ぢ 2021-01-12 14:57

Something I\'ve been thinking about from time to time: Why is the typeof operator needed in C#? Doesn\'t the compiler know that public class Animal is a type ju

6条回答
  •  不要未来只要你来
    2021-01-12 15:26

    Reflection for starters. Many possibilities become available when you can inspect the type itself, instead of just having to know what it exposes, or that it exists at all.

提交回复
热议问题