I have a file text which splited by newline character. the text file such this:
merah.dc
kuning.dc
hijau.dc
biru.dc
orange.dc
mahopermanent.dc
I want to count them by splitting with a newline character. so, the count of them are 6. I could only do this with looping:
int count = 0;
string path = "directory\\admin.txt";
StreamReader moco = File.OpenText(path);
string s;
while ((s = moco.ReadLine())!= null)
{
count++;
}
I want to count them with a simple way like the PHP syntax:
<?php
$file = file("directory\\admin.txt");
$count = count($file);
echo $count;
?>
The above syntax able to counts them without looping. Just use file()
and count()
. is any function in C# which equals with that function ?