以line command作为参数处理txt文件中的字符



我试图从文本文件中计算所有行和字符,元音和常量的数量,但我有这个问题。当我试着运行这个程序的时候有没有什么建议我应该如何解决这个问题,因为我试着把方法切换到静态的,但它根本没有帮助这里是计算行数的类,元音,辅音,和所有字符

public class Continut
{
static bool IsLetter(char c)
{
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
string fileName;
int nrlines = 0;
int nrvvowles = 0;
int nrtotalcharacters = 0;
int nrconsonant = 0;
string vocale = "aeiouAeiou";
public Continut  (string fileName)
{
fileName = Console.ReadLine();
}
public void FindFileAndWork(string fileName)
{                 
if (File.Exists(fileName))
{
StreamReader reader = new StreamReader(fileName);
string line = "";
while ((line = reader.ReadLine()) != null)
{
nrlines++;
nrtotalcharacters = nrtotalcharacters + line.Length;
for (int i = 0; i < line.Length; i++)
{
if (IsLetter(line[i]) == true)
{
if (vocale.IndexOf(line[i]) != -1)
{
nrvvowles++;
}
else
{
nrconsonant++;
}
}
}
}
}
else
{
Console.WriteLine("Folder dosen't exists");
}

}

}

主代码

internal class Program
{
static void Main(string[] args)
{
string filePath = Console.ReadLine();
Continut.FindFileAndWork(filePath);
}        



}
Continut.FindFileAndWork(filePath);

试图调用静态方法,但它不是静态的

也是如此
var ct = new Continut();
ct.FindFileAndWork(filePath);

你也需要一个空的构造函数

public Continut  ()
{

}

最新更新