Plz检查代码,并告诉我我的错误。我没有收到任何错误消息,但也没有输出。 [英] Plz check the codes and tel me wats wrong with this. I am not getting any error messages but also not the output.

查看:115
本文介绍了Plz检查代码,并告诉我我的错误。我没有收到任何错误消息,但也没有输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用系统; 
使用 System.Collections.Generic;
使用 System.IO;
使用 System.Text;

命名空间 ConsoleApplication1
{
class 计划
{
静态 void Main( string [] args)
{
string alphaFilePath = @ C:\ Users \trainee \ Documents \ visual studio 2010 \Projects\ConsoleApplication3 \ConsoleApplication3 \bin\Debug \ input.txt;

List< string> alphaFileContent = new List< string>();

使用(FileStream fs = new FileStream(alphaFilePath,FileMode.Open) )
使用(StreamReader rdr = new StreamReader(fs))
{
while (!rdr.EndOfStream)
{
alphaFileContent.Add(rdr.ReadLine());
}
}

string betaFilePath = @ C:\ Users \trainee \ Documents \ visual studio 2010 \Projects\ConsoleApplication3 \ConsoleApplication3 \bin\Debug\check.csv;

StringBuilder sb = new StringBuilder();


使用(FileStream fs = new FileStream(betaFilePath, FileMode.Open))
使用(StreamReader rdr = new StreamReader(fs))
{
while (!rdr.EndOfStream)
{
string [] betaFileLine = rdr.ReadLine()。Split(Convert.ToChar( ) );

if (alphaFileContent.Contains(betaFileLine [ 0 ]))
{
sb.AppendLine( String .Format( {0},{1},betaFileLine [ 0 ],betaFileLine [ 1 < /跨度>]));
}
}


}

使用(FileStream fs = new FileStream( @ C:\ Users \ trainee \Documents\visual studio 2010 \Projects\ConsoleApplication3 \ConsoleApplication3 \bin\Debug\result.txt,FileMode.Create))
using (StreamWriter writer = new StreamWriter(fs))
{
writer.Write(sb.ToString( ));
}

Console.WriteLine(sb.ToString());
}


}
}





我在这里读书来自第一个文件的输入。

然后我有一个csv格式文件,我检查输入文件中的匹配单词,如果找到一个我提取它并将其放在第三个文件中打印出来。



但我没有收到任何错误或输出。

我该怎么办?



需要帮助...

解决方案

可能是因为块没有满足条件

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string alphaFilePath = @"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\input.txt";

            List<string> alphaFileContent = new List<string>();

            using (FileStream fs = new FileStream(alphaFilePath, FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    alphaFileContent.Add(rdr.ReadLine());
                }
            }

            string betaFilePath = @"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\check.csv";

            StringBuilder sb = new StringBuilder();


            using (FileStream fs = new FileStream(betaFilePath, FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    string[] betaFileLine = rdr.ReadLine().Split(Convert.ToChar(","));

                    if (alphaFileContent.Contains(betaFileLine[0]))
                    {
                        sb.AppendLine(String.Format("{0}, {1}", betaFileLine[0], betaFileLine[1]));
                    }
                }


            }

            using (FileStream fs = new FileStream(@"C:\Users\trainee\Documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\result.txt", FileMode.Create))
            using (StreamWriter writer = new StreamWriter(fs))
            {
                writer.Write(sb.ToString());
            }

            Console.WriteLine(sb.ToString());
        }


    }
}



Here I am reading the input from the first file.
Then I am having a csv format file to which I check for matching words from the input file and if found one I extract it and put it up in the third file and print it.

But I am not getting any errors or the output.
What should i do ?

Help required...

解决方案

it may be because there is no condition met for the blocks


这篇关于Plz检查代码,并告诉我我的错误。我没有收到任何错误消息,但也没有输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆