返回空值,所以我有這樣的方法:從泛型方法
internal K GetValue<T, K>(T source, string col) where T : IBaseObject
{
string table = GetObjectTableName(source.GetType());
DataTable dt = _mbx.Tables[table];
DataRow[] rows = dt.Select("ID = " + source.ID);
if (rows.Length == 0) return K;
return (K) rows[0][col];
}
我希望能夠返回空值,或某種空值,如果沒有行被發現。什麼是正確的語法來做到這一點?