Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:49:13+00:00 2026-05-22T20:49:13+00:00

I need to translate this fragment from Java to .NET (rather C#, but I

  • 0

I need to translate this fragment from Java to .NET (rather C#, but I know Visual Basic too).
This is code:

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();
        }           
    }

First line (Dictionary class) is from .NET (my translation try ;)).
I know the Field class is from java.lang.reflect.Field, but I couldn’t found .NET equivalent.
Kind regards!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:49:14+00:00Added an answer on May 22, 2026 at 8:49 pm
    var typeStrings = new Dictionary<int, string>();
    
    FieldInfo[] fields = yourObject.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
    foreach (var field in fields)
    {
        typeStrings.Add((int)field.GetValue(yourObject), field.Name);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never used ruby but need to translate this code to java. Can
I need to translate this piece of code from Perl to Lua open(FILE, '/proc/meminfo');
I need to translate this C code to MIPS assembly. Here is the C
I got this a problem, I need translate this SQL Query to Criteria, but
I want to translate this java code into equal objective-c code double[] pMatrix =
How can I translate this Java code: private List<MPoint> classes = new ArrayList<MPoint>(); //
I need to port code from Java to C#. In the Java code, the
I have a case where I need to translate (lookup) several values from the
I have a code that need to be translated from C to Cpp, and
I have a C# web method that I need to translate to VB.NET. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.