我想第一次使用泛型,並嘗試將從數據庫返回的結果綁定到程序員定義的數據類型。我怎樣才能做到這一點。如何在這裏使用泛型
dsb.ExecuteQuery("DELETE FROM CurrencyMaster WHERE CurrencyMasterId="
+ returnValueFromGrid<int>(getSelectedRowIndex(), "CurrencyMasterId"));
private T returnValueFromGrid<T>(int RowNo, string ColName)
{
return Convert.ChangeType(dgvCurrencyMaster.Rows[RowNo].Cells[ColName].Value, T);
}
不要混合使用後引號和四空格縮進。只需要其中的一個來標記代碼。 – 2010-04-23 09:30:41
只要'由Jon Skeet編輯'出現... – amelvin 2010-04-23 09:31:29