Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to represent a TextFile as an Array
  2. var stopwordsarr = new string[] {"stopword1", "stopword2", "stopword3", "etc.."};
  3.        
  4. static void Main(string[] args) {
  5.   var fname = args[0];
  6.   var words = File.ReadAllLines(fname);
  7.  
  8.   Console.WriteLine("var stopWords = new string[] {");
  9.   for(int i = 0; i < words.Length; ++i) {
  10.     string word = words[i];
  11.     Console.Write("@"{0}"", word.Replace(""", "\""));
  12.     if(i < words.Length - 1) {
  13.       Console.Write(",");
  14.     }
  15.     Console.WriteLine();
  16.   }
  17.   Console.WriteLine("};");
  18. }
  19.        
  20. var stopWordsArr = File.ReadAllLines(path);