What is the difference between typeof and the is keyword?

前端 未结 6 1069
太阳男子
太阳男子 2021-01-03 19:11

What\'s the exact difference between the two?

// When calling this method with GetByType()

public bool GetByType() {
    // this ret         


        
6条回答
  •  梦毁少年i
    2021-01-03 19:57

    The is keyword checks if an object is of a certain type. typeof(T) is of type Type, and not of type AClass.

    Check the MSDN for the is keyword and the typeof keyword

提交回复
热议问题