[.NET] Enumerable.OfType 方法
之前都是使用 GetType 方式來使用,沒想到
.NET Framework 3.5 就有提供這個比較便利的方法
紀錄一下筆記資訊。
例如:
                //取得 Collection 中 TextBox 的控制項集合
                foreach ( TextBox tb in this.Controls.OfType<TextBox>()) 
                {
                    //....
                }
                //取得 Collection 中 Button 的控制項集合
                foreach (Button btn in this.Controls.OfType<Button>())
                {
                    //....
                }
參考資料: