ここで私の問題は次のとおりです。
私はこのコードを持っています:
static long CountLinesInFile(string f)
{
long count = 0;
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
count++;
}
}
return count;
}
テキストファイルの行数をカウントします。私が抱えている問題は、これを試しているときです:
textBox1.Text = CountLinesInFile("test.txt");
エラーが発生します:
Error 1 Cannot implicitly convert type 'long' to 'string'
合法のようですが、どうすれば文字列に変換できますか? Javaでは単純ですtoString()
誰かが私に解決策を教えてもらえますか?