1. is 是驗證操作對象是不是自己希望的
運算公式:對象 is 類型
返回true:對象是指定類型
返回false:對象不是指定類型
2. as 是將對象轉換成指定類型
運算公式:對象 as 類型
轉換成功:對象的類型就是指定的類型
轉換失敗:返回null
注意: The "is" and "as" operator must be used with a reference type or nullable type (example:'int' is a non-nullable value type)
新聞熱點
疑難解答