object obj = "Hello"; string s = obj as string; // 转换成功 System.IO.Stream stream = obj as System.IO.Stream; // 转换失败,stream 为 null if (stream != null) { /*...*/ }