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

  • SEARCH
  • Home
  • 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 7517733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:32:37+00:00 2026-05-30T01:32:37+00:00

Suppose i have the following class in C#: public class B : A {

  • 0

Suppose i have the following class in C#:

public class B : A
{
    public Int32 B_ID;
    public String B_Value;

    public Int32 getID()
    {
        return B_ID;
    }

    public void setID(Int32 value)
    {
        B_ID = value;
    }
}

Based on Reflection, can I get the name of the field used by getID() (and/or) setID() method? (in case, [B_ID])
I’m coding a persistence framework and it would be useful to identify the key name of a table, which is enclosed by both methods above.

It seems that ReturnParameter property of RuntimeMethodInfo has a property called Name that should help me with this, but it’s comming null.

To get that RuntimeMethodInfo object, i’m getting Members of an instance of B class using this BindingFlags enums:

  • BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly

How can I get this field name? This behavior should be the same with properties.

Thanks in advance

  • 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-30T01:32:39+00:00Added an answer on May 30, 2026 at 1:32 am

    I am afraid that’s impossible because the field name is the part of the implemented code and reflection has no clue how to retrieve it.
    Persistent frameworks usually use a kind of mapping to provide such information.For example you can use a xml file or you can use attirbutes over your fields to introduce them as key or columns of your table something like this :

    [Table(name="MyTable")]    
    public class B : A
        {
    
    [Key(column_name="id")]    
    public Int32 B_ID;
            public String B_Value;
    
            public Int32 getID()
            {
                return B_ID;
            }
    
            public void setID(Int32 value)
            {
                B_ID = value;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following classes: public class Test { public static void main(String[]
Suppose you have the following situation #include <iostream> class Animal { public: virtual void
Suppose I have the following thread: public class MyThread { public void run() {
Suppose I have the following: class dataClass { public: int someData; float moreData; void
Suppose I have the following code: class a { public: virtual void do_a() =
Suppose I have the following class: public class TestBase { public bool runMethod1 {
Suppose I have the following class: class Camera { public Camera( double exposure, double
Suppose you have the following class: class Test : ISerializable { public static Test
Suppose I have the following (trivially simple) base class: public class Simple { public
Suppose I have following code package memoryleak; public class MemoryLeak { public static int

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.