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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:16:22+00:00 2026-06-04T16:16:22+00:00

Been reading about out / ref and tuple , but for the life of

  • 0

Been reading about out/ref and tuple, but for the life of me cannot figure out how to implement a way to return three (3) values (whether within same method that calculates my main value, or with separate methods). I am able to perform a calculation with one value (the main value) which deals with pricing for a service.

Here is a snippet of what I’ve done to calculate that main value:

public class Calculations
{
    public decimal decFinancialAccount(QuoteData quoteData)
    {
        if (quoteData.StepAssetInformation.FinancialAccountDropDown
            == StepAssetInformation.FinancialAccount.None)
            return 0;
        else if (quoteData.StepAssetInformation.FinancialAccountDropDown
            == StepAssetInformation.FinancialAccount.One)
            return PriceQuote.priceFinancialAccount;
        else if (quoteData.StepAssetInformation.FinancialAccountDropDown
            == StepAssetInformation.FinancialAccount.Two)
            return (PriceQuote.priceFinancialAccount * 2);
        ...
        else
            return 0;
    }
    public decimal CalculateChapter7(QuoteData quoteData)
    {
        decimal total = PriceQuote.priceChapter7;

        ...
        total += this.decFinancialAccount(quoteData);

        return total;
    }
}

The above works out great. It obviously has other decimal‘s that are added, but you get the idea.

Now, I am wanting to perform additional calculations on the CalculateChapter7 value that is returned.

The first value is a DiscountChapter7 / discount (variable in method?) price: above a certain amount, discounts are applied for every increment of 50. I got no problem listing them all out if I have to (rather than complicating things for myself). There is no set formula for the discounts, I just created an Excel sheet to visualize my discounts (see below).

The second value is a CompareChapter7 / compare (variable in method?) price: for every discounted price I offer, a comparison is made to what other’s charge for the same service. Again, there is no formula per se, I just used an Excel sheet to figure those out arbitrarily.

In addition, I’d like to (within the “discount” and “compare”) do a simple subtraction to show “savings” (calculated price – discounted price = savings) and “difference” (other attorneys charge – discounted price = difference). I imagine when I get the two values above working that these additional two would be simple.

Here is my Excel sheet (just a small snippet):

Excel sheet with pricing I want

A few notes about that:

  1. Between 799 and 999 there are no discounts (the “rounded” column is just to bring those numbers to a 50 increment for my ease of use and are not relevant).
  2. The Excel formulas are pretty straightforward (fee – discounted price = savings; other attorneys charge – discounted price = difference) – which is what I am trying to attain within my code.

Can anyone provide a solid example of how to integrate the “discount” and “comparison” with my calculated price?

Thanks!

  • 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-04T16:16:23+00:00Added an answer on June 4, 2026 at 4:16 pm

    You need to create a new class that will contain all the return values. If it’s not going to be used anywhere else, you could nest the class inside the Calculations class as follows, but that’s up to you:

    public class Calculations
    {
        public class Result
        {
            public decimal Total { get; set; }
            public decimal Discount { get; set; }
            public decimal Comparison {get; set; }
        }
    
        public Result CalculateChapter7(QuoteData quoteData)
        {
            Result result = new Result();
            result.Total = ...;
            result.Discount = ...;
            result.Comparison = ...;
            return result;
        }
    }
    

    When you do it this way, all three return values are packaged up into a single object which is then returned. Each time you call the method, it creates a new Result object and populates it with all the values for that invocation of the method. So, to read the returned values after calling the method, you would need to read each property out of the returned object. For instance you could do something like this:

    Calculations calc = new Calculations();
    Calculations.Result result = calc.CalculateChapter7(...);
    string output = string.Format("Total = {0}, Discount = {1}, Comparison = {2}", result.Total.ToString(), result.Discount.ToString(), result.Comparison.ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading about the issue with trying to figure out the actual
I have been reading about out of memory conditions on Linux, and the following
I'm just starting out with unit testing in C#. I have been reading about
I've been reading about cryptography for quite a while now, but it still bother
I've been reading a lot about this problem but I get nothing that suggests
I have been reading about try/finally on MSDN and found out following code. They
I've been reading about Role Based Access Control and I am trying to figure
I've been reading about the @font-face rule and trying to work out if it's
I've been reading a lot about Facebook's PHP HipHop project, but one thing I
i have been reading about proximity security devices through bluetooth, but i am wondering

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.