C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,487 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
HResult=0x80131500
Message=Operator '==' cannot be applied to operands of type 'string[]' and 'Microsoft.Office.Interop.Word.WdPartOfSpeech'
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Here is the rest of the code snippet, which has compilation errors that included the message above.
private void BSearchForVerbs_Click(object sender, EventArgs e)
{
LBSelectedVerbs.Items.Clear();
Globals.ThisAddIn.Application.Selection.MoveRight(WdUnits.wdWord, 1, WdMovementType.wdExtend);
string wordText = Globals.ThisAddIn.Application.Selection.Text;
var synonymInfo = Globals.ThisAddIn.Application.SynonymInfo[wordText];
if (synonymInfo.Found.Equals(true) && synonymInfo.RelatedWordList == WdPartOfSpeech.wdVerb)
{
LBSelectedVerbs.Items.Add(wordText);
}
// Check if this word can be a verb
Globals.ThisAddIn.Application.Selection.MoveRight(WdUnits.wdWord, 1, WdMovementType.wdMove);
}
Try something like this:
if( synonymInfo.Found )
{
Array pa = (Array)(object)synonymInfo.PartOfSpeechList;
for( int i = 1; i <= synonymInfo.MeaningCount; ++i )
{
if( (WdPartOfSpeech)pa.GetValue( i ) == WdPartOfSpeech.wdVerb )
{
Array sa = (Array)(object)synonymInfo.SynonymList[i];
foreach( string s in sa )
{
LBSelectedVerbs.Items.Add( s );
}
}
}
}
It is also possible to find the distinct words.