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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:16:50+00:00 2026-06-12T09:16:50+00:00

I am trying to create a new object of type Invoice. I pass in

  • 0

I am trying to create a new object of type Invoice. I pass in the necessary parameters in the correct order.

However, it is telling me that I have included invalid arguments. I might be overlooking something very simple here, but maybe someone can point it out.

I am working on homework, however the Invoice.cs file was included for use with the project.

The only solution I am seeking is why my object will not accept the values. I have never had an issue with objects before.

Here is the code I have:

static void Main(string[] args)
{
    Invoice myInvoice = new Invoice(83, "Electric sander", 7, 57.98);
}

And here is the actual Invoice.cs file:

// Exercise 9.3 Solution: Invoice.cs
// Invoice class.
public class Invoice
{
   // declare variables for Invoice object
   private int quantityValue;
   private decimal priceValue;

   // auto-implemented property PartNumber
   public int PartNumber { get; set; }

   // auto-implemented property PartDescription
   public string PartDescription { get; set; }

   // four-argument constructor
   public Invoice( int part, string description,
      int count, decimal pricePerItem )
   {
      PartNumber = part;
      PartDescription = description;
      Quantity = count;
      Price = pricePerItem;
   } // end constructor

   // property for quantityValue; ensures value is positive
   public int Quantity
   {
      get
      {
         return quantityValue;
      } // end get
      set
      {
         if ( value > 0 ) // determine whether quantity is positive
            quantityValue = value; // valid quantity assigned
      } // end set
   } // end property Quantity

   // property for pricePerItemValue; ensures value is positive
   public decimal Price
   {
      get
      {
         return priceValue;
      } // end get
      set
      {
         if ( value >= 0M ) // determine whether price is non-negative
            priceValue = value; // valid price assigned
      } // end set
   } // end property Price

   // return string containing the fields in the Invoice in a nice format
   public override string ToString()
   {
      // left justify each field, and give large enough spaces so
      // all the columns line up
      return string.Format( "{0,-5} {1,-20} {2,-5} {3,6:C}",
         PartNumber, PartDescription, Quantity, Price );
   } // end method ToString
} // end class Invoice
  • 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-12T09:16:51+00:00Added an answer on June 12, 2026 at 9:16 am

    Your method is expecting a decimal parameter where as you are passing a double value (57.98).

    Per MSDN (see Remarks section),

    There are no implicit conversions between floating-point types and the
    decimal type.

    For decimals you should add suffix ‘m’ or ‘M’

    So, in your case, pass 57.98m instead of 57.98

    This SO answer lists all kinds of suffixes.

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

Sidebar

Related Questions

I'm trying to create a new object of type T via its constructor when
I'm trying to create instances of objects that have the same base type like
I am using backbone and trying to create a new object and I am
In my example, I'm trying to create a new object which has references to
This is just a simple question. I was trying to create a new object
I am trying to create a new date object from string as follows: var
I'm trying to create a new System.Threading.Thread object using Jscript, but I can't get
Whats wrong in below JSON Object definition I am trying to create a new
Trying to create COM -object on server. code is: var myGuid = new Guid(530A1815-820C-11D3-BBB7-008048DE406A);
I am trying to create an object pool which will have objects of diffrent

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.