Best View in Google Crome, Mozilla firefox or IE 7 or above
Sunday, March 6, 2011
Wednesday, January 12, 2011
Find number of words in a text file in C# Dotnet
using System;
using System.IO;
namespace ConsoleApplication1
{
class CountWords
{
public string content { get; set; }
internal int wordsInFile(string P)
{
return File.ReadAllText(P).Split(' ').Length;
}
}
class Program
{
static void Main(string[] args)
{
CountWords c = new CountWords();
int numWords = c.wordsInFile(@"C:\test_data.txt");
Console.WriteLine(numWords);
Console.ReadLine();
}
}
}
Text and Speech Project in C# Dotnet
Labels:
c# dotnet code,
count words in a file
Subscribe to:
Posts (Atom)