null-cast

    12熱度

    5回答

    哪種方式是優選的表情是這樣的: int? Id { get { int i; return Int32.TryParse(Request["id"], out i) ? i : (int?)null; } } 是它更好地施放null或創建new Nullable<T>?

    1熱度

    2回答

    鑑於空鑄: var result = MyMethod((Foo) null); 是否有可能使用與反射的方法內這些額外的信息? 編輯: 方法的簽名是這樣的: object MyMethod(params object[] args) { // here I would like to see that args[0] is (was) of type Foo }