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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:52:54+00:00 2026-05-17T21:52:54+00:00

Im sure this is simple but I’ve looked at it too long and I

  • 0

Im sure this is simple but I’ve looked at it too long and I need an answer soon. I am new to C#. If I put GetCommission()
within the struct I get

error CS0188: The ‘this’ object cannot be used before all of its fields are assigned to

outside the struct

error CS0038: Cannot access a non-static member of outer type ‘Ex5._3.CommissionForm’ via nested type ‘Ex5._3.CommissionForm.salespersonFigures’

How do I get this done? Caveat: part of the assignment was that the commission be calculated in a method. None of the struct tutorials I’ve found deal with assigning one member based on the value of another. It should be kosher as the calculations only use static data. Right?

// Declare class variables and constants
private const decimal WEEKLY_BASE_SALARY = 250m;
private const decimal WEEKLY_QUOTA = 1000m;
private const decimal COMMISSION_RATE = .15m;

public struct salespersonFigures
{
    // Fields
    private string salesperson;
    private decimal weeklySales;
    private decimal commission;
    private decimal pay;

    // Constructor
    public salespersonFigures(string name, decimal sales)
    {
        salesperson = name;
        weeklySales = sales;
        commission = GetCommission(sales);  // error occurs at this line
        pay = WEEKLY_BASE_SALARY + commission;
    }

    // Property

    public decimal Sales
    {
        get
        {
            return weeklySales;
        }
        set
        {
            weeklySales = value;
        }
    }

    public string Name
    {
        get
        {
            return salesperson;
        }
        set
        {
            salesperson = value;
        }
    }

    // Method

    public decimal GetCommission(decimal sales)
    {
        if (sales > WEEKLY_QUOTA)
            return sales * COMMISSION_RATE;
        else return 0m;
    }
}
  • 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-17T21:52:55+00:00Added an answer on May 17, 2026 at 9:52 pm

    The constructor:

    // Constructor
    public salespersonFigures(string name, decimal sales)
    {
        salesperson = name;
        weeklySales = sales;
        commission = GetCommission(sales);
        pay = WEEKLY_BASE_SALARY + commission;
    }
    

    Is being interpreted as:

    // Constructor
    public salespersonFigures(string name, decimal sales)
    {
        this.salesperson = name;
        this.weeklySales = sales;
        this.commission = this.GetCommission(sales);
        this.pay = WEEKLY_BASE_SALARY + this.commission;
    }
    

    So, the problems you could be encountering could be resolved by doing two things:

    // Constructor
    public salespersonFigures(string name, decimal sales)
    {
        salesperson = name;
        weeklySales = sales;
        var tempCommission = GetCommission(sales);
        commission = tempCommission
        pay = WEEKLY_BASE_SALARY + tempCommission;
    }
    

    And make the GetCommission method static

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

Sidebar

Related Questions

I'm sure this is a simple thing to do but in php I need
I'm sure this is quite simple but I can't find the answer. I'm passing
I'm sure this is simple but if I need to display numbers dynamically using
I am sure this is very simple but I can't find an answer anywhere.
I'm sure this is going to be an 'oh geez' simple answer, but I
Im sure this is simple but newbie here. I have 5 URLS cards.php&type=one cards.php&type=two
I'm sure this is simple but I can't figure out how to achieve it:
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
Im sure this is pretty simple but I just cant seem to find the
I'm sure this is something simple but I've been staring at it for a

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.