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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:56:03+00:00 2026-06-17T14:56:03+00:00

Well i have the following classes: Player manager (which add players, remove, etc) Player

  • 0

Well i have the following classes:

  • Player manager (which add players, remove, etc)
  • Player (it does all sort of things)
  • Client (it contains network actions like sending data, recv, etc).

Player manager have an array of Player class and Client class is a composition of Player, with private access because i dont need the user see the Client interface.

It all comes fine, except the problem that i want to use array fixed length instead of a list.
Client class is determined at run time and if i want to initialize a player i would need to set it directly on the property or using a setter method, this forces me to make the Client composition as public.

List works perfectly fine on this problem because i can set the Client property on the constructor of Player class, but the idea is to use array fixed length because is faster. Is there any work around to keep Client as private and set it from Player Manager class?

public class PlayerManager
{
    public Player[] players { get; set; }

    public PlayerManager(int maxplayers)
    {
        players = new Player[maxplayers];
    }

    public void Add(Client client)
    {
        Player player = FindPlayerSlot();
        player.client = client; //cant do this, client is private property
    }

}

public class Player
{
     private Client client { get; set; } //Need to hide this from user

     //I can set a constructor here for set the client property, but this would
     //force me to use a list.
}
  • 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-17T14:56:04+00:00Added an answer on June 17, 2026 at 2:56 pm

    Try making it an internal property. The internal keyword makes a type or member invisible outside of the assembly it’s defined in.

    That’s assuming this is all in a single assembly and the user will be referencing your assembly and using it. If you have more than one assembly you need the internals visible to, you can use [assembly: InternalsVisibleTo("MyOtherAssembly")] to define the only other assemblies that have access to the members marked as internal.

    Additionally, a List<Client> isn’t going to be any slower than a fixed array except for when it’s resizing. If you use the List constructor with an initial capacity, you can get the same performance as a fixed array.

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

Sidebar

Related Questions

I have the following function which works very well within a $(document).ready(function(){ $('.threadWrapper >
I have the following script which works fairly well: $(.btnMinimize).live('click', function(event) { event.preventDefault(); $(
I have the following classes. For testing purpose, I would like to get all
I have the following script that works well in Firefox and Chrome (not sure
I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
I have the following code that compiles and works well: template<typename T> T GetGlobal(const
I have the following problem that the standard library doesn't solve well, and I'm
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {
I have the following classes: Defect - represents a type of data that can
I have the following classes... public class Order { private Guid id; public Guid

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.