C# : 'is' keyword and checking for Not

后端 未结 12 2013
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 05:23

This is a silly question, but you can use this code to check if something is a particular type...

if (child is IContainer) { //....

Is ther

12条回答
  •  爱一瞬间的悲伤
    2020-12-02 05:48

    Why not just use the else ?

    if (child is IContainer)
    {
      //
    }
    else
    {
      // Do what you want here
    }
    

    Its neat it familiar and simple ?

提交回复
热议问题