有沒有辦法在以下string
變量上使用的Rowfilter
屬性?使用C#DataView.RowFilter屬性的函數的字符串類型的參數
public DataTable FilterByLatestDate(DataTable tbl, string date_asof)
{
DataView latest = tbl.DefaultView;
//latest.RowFilter = "[date]= '" + date_asof + "'" ; //
//latest.RowFilter = string.Format("[date]= '{0}'", date_asof); // alternative to messing around with quotes
DataTable last_tbl = latest.ToTable();
return last_tbl;
}
PS:我只在涉及建議感興趣.Rowfilter
最佳
格式化或使用C#6.0的語法和只寫'$ 「[日期] =#{date_asof}#」'。 – Adwaenyth
仍然以'#4.0',但感謝您的信息。 –