Pages

Thursday, June 4, 2015

Function of Character Count in C#

public static int CharCount (StreamReader strIn) 

int c;   
int fileSize = 0;
while ((c = strIn.Read()) != -1) 
++fileSize; 
return fileSize;
}

public static void Main (string[] args) 
{
 StreamReader strIn = new StreamReader(“d:\\test.txt”);
 Console.WriteLine("char count is " + CharCount( strIn)); 
strIn.Close(); 
}

No comments:

Post a Comment