Enum values for Office interop via dynamic object

亡梦爱人 提交于 2019-12-02 02:25:13

Tools like Reflector make that fairly simple. You could even use ILDASM that comes with part of the .NET Framework.

You can load the Primary Interop Assembly with either of those two tools. Reflector shows the C# source as:

public enum WdCollapseDirection
{
    wdCollapseEnd,
    wdCollapseStart
}

Since they have no explicit values, wdCollapseEnd is 0 and wdCollapseStart is 1. We can confirm with the IL view:

.class public auto ansi sealed WdCollapseDirection
    extends [mscorlib]System.Enum
{
    .field public specialname rtspecialname int32 value__

    .field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseEnd = int32(0)

    .field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseStart = int32(1)

}

ILDASM shows this:

.field public static literal valuetype Microsoft.Office.Interop.Word.WdCollapseDirection wdCollapseEnd = int32(0x00000000)

If you have a tool like Resharper, doing Ctrl+Q on it directly from within Visual Studio shows this:

You could have a dummy project that you can use to look up the values.

As an additional option, if you use LINQPad you could reference the Word Primary Interop Assembly (Microsoft.Office.Interop.Word - should be in the GAC) and run this:

void Main()
{
    var value = (int) Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseStart;
    Console.Out.WriteLine("value = {0}", value);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!