2012-02-27 127 views
2

我正在編寫使用Word.dll進行拼寫檢查的c#代碼。我用下面的網站參考: http://www.codeproject.com/Articles/2469/SpellCheck-net-spell-checking-parsing-using-Cc中的拼寫檢查#

但我得到一個錯誤:「類型或命名空間名稱‘字’找不到(是否缺少using指令或程序集引用?)」

,我使用的代碼是:

SpellCheck word = new SpellCheck(); 

    bool status = false; 
    string s = "youes"; 

    Console.WriteLine("Checking for word : " + s); 

    // check to see if the word is not correct 
    // return the bool (true|false) 
    status = word.CheckSpelling(s); 

    if (status == false) 
    { 
     Console.WriteLine("This word is misspelled : " + s); 
     Console.WriteLine("Here are some suggestions"); 
     Console.WriteLine("-------------------------"); 

     foreach(string suggestion in word.GetSpellingSuggestions(s)) 
     { 
      System.Console.WriteLine(suggestion); 
     } 
    } 
    else if (status == true) 
    { 
     Console.WriteLine("This word is correct : " + s); 
    } 

我只是想知道我怎樣才能使它發揮作用?

+0

'下添加refernce到Micorsoft.Office.Interop.Word;'這是你的代碼的頂部? – Bolu 2012-02-27 09:47:38

回答

1

在您的解決方案中創建一個新類並將其稱爲Word.cs. 打開the article at CodeProject中的「瀏覽代碼」標籤,單擊Word.cs查看其源代碼。複製並粘貼到您的Word.cs文件。

1

您應該下載源代碼。有一個名爲Word.cs的文件,您應該將該文件添加到您的項目中。 Word名稱空間和SpellCheck類在該文件中定義。

0

我想你應該淨

使用Word