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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:42:56+00:00 2026-06-10T13:42:56+00:00

Imagine I have this class: Class Foo { public Bar b1 { get; set;

  • 0

Imagine I have this class:

Class Foo
{
    public Bar b1 { get; set; }
    public Bar b2 { get; set; }
    public Bar b3 { get; set; }

    public void UpdateBarsMyProp(bool value)
    {
        // ????
    }
}

Class Bar
{
    public bool MyProp { get; set; }

    public bool UpdateMyProp(bool value)
    {
        this.MyProp = value;
    }
}

What’s the best way to update the property MyProp in b1, b2 and b3?

Generics?

Delegates?

EDIT:

Just to add more information about my specific situation:

I’m creating a virtual keyboard and I’m using WPF MVVM so I have:

A KeyBoard ViewModel which contains several Key ViewModels, I can’t store them in a List because im my View (xaml file) I need to bind each key information to a specific ViewModel.

Now, when the user presses the virtual shift button, I need my Keyboard ViewModel object to update the display char in every Key ViewModel.

  • 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-10T13:42:57+00:00Added an answer on June 10, 2026 at 1:42 pm

    You could put your properties in a List<Bar> (or an array if you prefer…) and iterate over it.

    So:

    public Bar b1 { get; set; }
    public Bar b2 { get; set; }
    public Bar b3 { get; set; }
    // other Bar props...
    
    private List<Bar> barsList = new List<Bar>(){ b1, b2, b3, ... };
    
    public void UpdateBarsMyProp(bool value)
    {
        foreach(Bar bar in barsList)
        {
            bar.MyProp = value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have : class Foo { public: Foo(std::function< void(std::shared_ptr< Foo >) > callback);
Imagine I have this class public class Case { [Key] [DataMember] public int CaseId
Imagine I have this class public class Case { [Key] [DataMember] public int CaseId
Imagine I have a class in C# called Bar that has a public function
Assume we have legacy classes, that can't be modified: class Foo { public void
Imagine I have the following code: class A { [UsefulAttribute(foo)] B var1; [UsefulAttribute(bar)] B
Say I have some code like this: class Foo { public: Foo(int v) :
Imagine I have a template function like this: template<typename Iterator> void myfunc(Iterator a, typename
Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id =
Im playing a little bit with heavy-client app. Imagine I have this model: class

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.