有没有办法在以下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',但感谢您的信息。 –