将代码从Java转换为.NET

Zoz*_*ozo 1 .net c# java translation equivalent

我需要将这个片段从Java翻译成.NET(而不是C#,但我也知道Visual Basic).这是代码:

typeStrings = new Dictionary<Int16, String>();

    Field[] fields = Type.class.getDeclaredFields();

    for (Field field : fields) {
        try {
            typeStrings.put(field.getInt(null), field.getName());
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }           
    }
Run Code Online (Sandbox Code Playgroud)

第一行(Dictionary类)来自.NET(我的翻译尝试;)).我知道Field类来自java.lang.reflect.Field,但我找不到.NET等价物.亲切的问候!

SLa*_*aks 7

你正在寻找System.Reflection.FieldInfo班级和typeof(SomeType).GetFields().