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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:01:49+00:00 2026-05-27T15:01:49+00:00

May be this is a newbie question but here it is. I am developing

  • 0

May be this is a newbie question but here it is.
I am developing a card game and i hava a class named Player …
Player has a property called Partner ( another Player ) and another property called Points.

public class Player
{ 
   public Player()
   {
   }
   public Player Partner { get; set; }

   private int points = 0;
   public int Points 
   { 
   get { return points;}
   set { 
       if (Partner != null) Partner.Points = value;
       points = value; 
       } // -> Here is the problem cause p1.Partner = p2 and p2.Partner = p1
   }

The question is : How is the most “elegant way” to set the Points property for a player and have its Partner points property set automatically ?

For instance:

Player p1 = new Player();
Player p2 = new Player();
p1.Partner = p2;
p2.Partner = p1;
p1.Points = 10;
int p = p2.Points

p should be equal to 10.

Thanks in advance ,
Marcelo
Brazil< .

  • 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-27T15:01:49+00:00Added an answer on May 27, 2026 at 3:01 pm
    set { 
        points = value; 
        if (Partner != null && Partner.Points != value)
        {
            Partner.Points = value;
        }
    }
    

    Will fix the circular reference, but having a Partnership object that they both refer to get the total points will be cleaner and allows each player to store the individual points they’ve scored too.

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

Sidebar

Related Questions

I know this is a total newbie question, but the answer may not be
may be this is newbie question, but I must ask it! In general I'm
This may be a newbie question, But let's say I have a database table
This may sound a newbie question ... but however I'm new to iOS development.
This may be a newbie question. I've used javascript for years but have only
This may be a basic question... but I am a newbie to jquery. I
This may be a newbie question, but i want to avoid buffer overflow. I
This may be a bit of a newbie question, but I just don't know!
OK, this may be a newbie question, but how/where can I subscribe to the
This may seem like a newbie question, but what is the proper way to

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.