我有一个我正在处理的程序的一部分需要过滤掉所有不必要的行,并且只根据从我的表单上的日期时间选择器控件中选择的开始和结束日期保留必要的行..csv文件包含以下所有日期作为示例:
如果我的日期时间选择器已被选中作为2015年2月18日开始,结束日期为2015年3月2日,我希望只能将这些项目包含在我的数据表中.我有一个方法已经反转数据行,但我需要知道如何过滤掉小于或等于结束日期,大于或等于开始日期的值.我的计划是在一个单独的方法中完成过滤,在该方法中,我传递通过读取.csv文件创建的现有表.
我的代码到目前为止如下:
public DataTable PopulateTable()
{
DataTable stockTable = new DataTable();
try
{
FileStream stream = new FileStream(BuildFilePath(), FileMode.Open);
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Unable to open filepath");
}
StreamReader reader = new StreamReader(BuildFilePath());
string header = "";
string line = "";
char[] delimeter = { ',' };
string[] headerData;
string[] rowData;
//read the header and add the names to the columns of the data …Run Code Online (Sandbox Code Playgroud)