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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:13:32+00:00 2026-05-22T20:13:32+00:00

It seems like this question gets asked frequently, but having looked through all of

  • 0

It seems like this question gets asked frequently, but having looked through all of them, I find I’m still without aid. I’m taking my first step into oop, and I need to create an object with an attribute “Products” that is an array of up to 7 possible objects of class “Product”. I just just barely understand the {get;set;} method, and am reading up on it, but I was hoping I could get some help with the syntax of what I’m trying to do here. I’m using C#. My code is below:

public class Submission 
{

    public Submission() {}
    public int SubmissionId {get;set;}

    public int CustId {get;set;}

    public int BroId {get;set;}

    public int Coverage {get;set;}

            public Array Products // what goes here? It's a mystery. 
} 
  • 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-22T20:13:33+00:00Added an answer on May 22, 2026 at 8:13 pm

    In this case, I think you don’t want an auto-implemented property. Instead, do it like this:

    //backing store for your public property
    private Product[] _products = new Product[7];
    
    public Product[] Products { get {return _products;}}
    

    and then in the constructor:

    foreach(var item in _products) {item = new Product(); }
    

    You could do this with a private setter rather than an explicit backing store, but I think this way is easier as far as setting up the size of the array goes.

    Notice that I only provided a getter for the property. You don’t want a setter, as that would allow someone to replace your property with a whole new array. Just providing a getter will still allow someone to manipulate the property. Also, normally I would recommend a collection rather than an array for this, but since you want a fixed-size for the number of items an array might be a better fit.

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

Sidebar

Related Questions

It seems that this question gets asked frequently , but I am not coming
This seems like the simplest Git question, but I can't find ANYTHING on it.
This seems like a basic question, but it's still bugging me. Why doesn't MyObject
I know this seems like a repeat question, but i've read all the others
this seems like a simple enough question but I can't seem to find a
This seems like a repeated question but i'm not able to get my answer.
This seems like a basic question, but I haven't found any clear answers. Essentially,
This seems like a simple question, but it is difficult to search for. I
I thought this question would have been asked before, but I couldn't find it
I tried searching for this, but couldn't find much. It seems like something that's

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.