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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:16:44+00:00 2026-05-26T23:16:44+00:00

I have following classes. In instance of BE (let’s say objBE) i want to

  • 0

I have following classes. In instance of BE (let’s say objBE) i want to select property name on run time and assign it’s value. e.g. we have a combo with all properties populated, and have text box and command button on window form. I want to select property name from the combo and type some value in text box and on button click i want to find the property name from the objBE and assign the text box value to the selected property. Couldn’t get way how to get it done. Can some help.
Thanks in Advance.
H N

public class MyPropertyBase
{
    public int StartOffset { get; set; }
    public int EndOffset { get; set; }
}

public class MyProperty<T> : MyPropertyBase
{
    public MyProperty(T propertyValue)
    {
        PropertyValue = propertyValue;
    }

    public T PropertyValue { get; set; }

    public static implicit operator MyProperty<T>(T t)
    {
        return new MyProperty<T>(t);
    }
}

public class BE
{
    private List<Admin_Fee> _Admin_Fee = new List<Admin_Fee>();

    public MyProperty<int> RFID
    {get;set;}
    public MyProperty<string> CUSIP
    {get;set;}
    public MyProperty<string> FUND_CITY 
    {get;set;}

    public MyProperty<int> SomeOtherProperty { get; set; }
    //public List<MyPropertyBase> MyDataPoints { get; set; }
    public List<Admin_Fee> Admin_Fee 
     {
         get{return _Admin_Fee;}
         set{}
     }
}
  • 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-26T23:16:45+00:00Added an answer on May 26, 2026 at 11:16 pm

    You can use GetProperty on the Type, then use SetValue on the PropertyInfo instance. Based on your description, I think you want something like this:

    void Main()
    {
        BE be  = new BE();
        SetMyPropertyValue("RFID", be, 2);
        SetMyPropertyValue("CUSIP", be, "hello, world");
    
        Console.WriteLine(be.RFID.PropertyValue);
        Console.WriteLine(be.CUSIP.PropertyValue);
    }
    
    private void SetMyPropertyValue(string propertyName, object instance, object valueToSet) 
    {
        Type be = instance.GetType();
        Type valueType = valueToSet.GetType();
        Type typeToSet = typeof(MyProperty<>).MakeGenericType(valueType);
        object value = Activator.CreateInstance(typeToSet,valueToSet);
    
        var prop = be.GetProperty(propertyName);
        prop.SetValue(instance, value, null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have following ORM classes (fields removed to simplify): class Animal(models.Model): say
Let's say I have the following classes and interfaces in my MVC 2 project:
With Castle Windsor, let's say I have the following classes: public class LowLevelComponent {
I have the following classes in my ActiveRecord model: def Property < ActiveRecord::Base #
I'm trying to learn interfaces and want to try the following: Let's say I
Say I have the following classes public class TestA { public string Blah {
Let's say I have some classes defined as follows: class Security { Boolean AuthenticateUser(String
Suppose, I have following classes: public class DisposableObj : IDisposable { public ChildObj CreateObj();
I have the following classes generated by the Reverse engineering tool (Entity Framework Power
I have the following classes. I have a object var of Description class. I

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.