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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:02:49+00:00 2026-05-12T09:02:49+00:00

Update Sorry. I didn’t mean the whole reflection library was off limits. I just

  • 0

Update
Sorry. I didn’t mean the whole reflection library was off limits. I just meant the insanely slow *.Invoke() stuff.

Hi,

I need to implement a property system in C# that allows both normal property access

[property_attribute()]
return_type Property { get; set; }

and access by string

SetProperty(string name, object value);
object GetProperty(string name);

However,

  1. I do not want to register each property individually.
  2. I do not want to use reflection
  3. I do not want to access properties through a dictionary (i.e. no PropertyTable["abc"]=val;)

This scheme is required for a cluster computing scheme where I have to set properties remotely and locally. All the properties will have a custom attribute that will be read at initalization. I hope to get constant run-time performance.

Currently, my idea is to have a custom parser/preprocesser parse/compile the scripts at runtime and generate the set/get code as follows:

object GetProperty(string name)
{
     if(name = "blah")
           return Property1;
     ...
}
...

However, I won’t be able to debug the code with this scheme. Can anyone think of a solution?

Thanks

  • 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-12T09:02:49+00:00Added an answer on May 12, 2026 at 9:02 am

    Your best option is to generate a dynamic method at runtime using System.Reflection.Emit. You’ll get great performance, and once you have it working right, debugging shouldn’t be a problem. (You should be able to depend upon it working, I can’t see why not).

    I prefer the dynamic method approach because it doesn’t depend on code generation at compile time or attribute marking or anything of that sort of thing. You can get it to work on any object and it will work for all public gettable/settable properties for that object.

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

Sidebar

Related Questions

[ Update: Changed question title to be more specific] Sorry if I didn't make
update: I know there is no one best way to do everything. Sorry for
Sorry for the double post, I will update this question if I can't get
Sorry if that title didn't explain it well. Here is the table... (source: alexanderdickson.com
I've looked but didn't find previous questions specific enough, so sorry if this is
Sorry for the lengthy post, I just want to illustrate my situation as best
UPDATE: Silly me didn't notice that the CASE wasn't exact. I was struggling with
I didn't know if this should be posted here or on Programmers - Sorry.
Update* I am so sorry... my sample code contained an error which resulted in
Sorry i really didn't know how to phrase the question any better but here

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.