Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带有数据表的if语句_C#_Winforms_If Statement_Datatable - Fatal编程技术网

C# 带有数据表的if语句

C# 带有数据表的if语句,c#,winforms,if-statement,datatable,C#,Winforms,If Statement,Datatable,简介:- 在第一列中包含文件名列表的两个数据表。 使用datatable A中的文件名“搜索”datatable B并用结果更新第三个datatable 正在使用If语句来处理foundRows部分 有没有关于如何让它发挥作用的提示 // Iterate through the leftFileDT, extract the filename & search rightFileDT for (int i = 0; i < leftFileDT.Ro

简介:-
在第一列中包含文件名列表的两个数据表。 使用datatable A中的文件名“搜索”datatable B并用结果更新第三个datatable

正在使用If语句来处理foundRows部分

有没有关于如何让它发挥作用的提示

        // Iterate through the leftFileDT, extract the filename & search rightFileDT
        for (int i = 0; i < leftFileDT.Rows.Count - 1; i++)
        {
            // Extract the leftFileName & store it in a string variable
            leftFileMatch = leftFileDT.Rows[i][0].ToString();

            // Search the rightFileDT for the leftFileMatch string
            string expression;
            expression = "Right_File_Name = '" + leftFileMatch + "'";
            DataRow[] foundRows;
            foundRows = rightFileDT.Select(expression);

            // If no match is found
            if (notfound)
            {
                matchedFileDataRow["File_Match"] = "False";
                matchedFileDataRow["Left_File_Name"] = leftFileMatch;
                matchedFileDT.Rows.Add(matchedFileDataRow);
            }
            // If a match is found
            if (found)
            {
                // Update the matchedFileDT datatable
                matchedFileDataRow["File_Match"] = "True";
                matchedFileDataRow["Left_File_Name"] = leftFileMatch;
                matchedFileDT.Rows.Add(matchedFileDataRow);

            }



        // Report progress to 'UI' thread
        comparerWorker_Left.ReportProgress(i);
//遍历leftFileDT,提取文件名并搜索rightFileDT
对于(int i=0;i
数据表的Select方法返回符合筛选条件的行数组。
如果没有匹配的行,则数组为空

DataRow[] foundRows = rightFileDT.Select(expression);
if (foundRows.Length == 0)
{
    matchedFileDataRow["File_Match"] = "False";
}
else
{
    matchedFileDataRow["File_Match"] = "True";
}
matchedFileDataRow["Left_File_Name"] = leftFileMatch;
matchedFileDT.Rows.Add(matchedFileDataRow);

在数组中调用
ToString()
对您没有帮助。请使用类似于
bool found=foundRows.Count>0的方法。与论坛网站不同,我们不使用“谢谢”或“感谢任何帮助”或签名。请参阅。