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 8017771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:56:15+00:00 2026-06-04T20:56:15+00:00

While using reflection is it possible to extract objects or variables no matter static

  • 0

While using reflection is it possible to extract objects or variables no matter static or not. for example

class MainApp
{
    static void Main()
    {            
        ConcretePrototype1 p1 = new ConcretePrototype1("I");
        ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone();
        Console.WriteLine("Cloned: {0}", c1.Id);
    }
}

Is it possible to extract

  1. p1 and c1 both so i can check its type

  2. the method call from p1.clone()

so far this is what i have done with a resulting array with 0 elements

I am loading Assembly from other file

var name = System.Reflection.Assembly.LoadFile(open.FileName);
name.GetType("PrototypePattern.MainApp").GetFields(BindingFlags.GetField|BindingFlags.Instance)
  • 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-06-04T20:56:16+00:00Added an answer on June 4, 2026 at 8:56 pm

    If you want to extract all fields (private/public/static/non-static) use:

    type.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
    

    Edit

    You cannot get variables and methods calls inside methods using simple reflection. This requires actually reading the bytecodes of the method and analyzing it – not an easy task.

    If you’re still keen on it, I suggest checking out libraries such as Mono.Cecil or CCI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I use magic methods. While using reflection API, I can't investigate class properties..
I've encountered a weird issue while using Reflection. So I have a domain class
I've got a problem converting an object property to string while using reflection... string
Long time ago, I was creating a mini ORM using reflection. While reading about
While using reflection in C#, you're expected to pass an object[] of the parameters
OK, I've been working on something for a while now, using reflection to accomplish
I need to set the properties of a class using reflection. I have a
While using uiimagepicker, is there any way of specifying which user created album the
While using asserts for e.g try{ assert email!=null : Email is required } catch
While using javascript in developing ,say a photo blog where you retrieve all 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.