2012-02-27 114 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