How can I use generic here.
Posted
by Shantanu Gupta
on Stack Overflow
See other posts from Stack Overflow
or by Shantanu Gupta
Published on 2010-04-23T09:27:56Z
Indexed on
2010/04/23
9:33 UTC
Read the original article
Hit count: 436
I am trying to use generic for the first time and trying to typecast my result returned from database to programmer defined data type. How can I do this.
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);
}
© Stack Overflow or respective owner