Hi its me again, I have an error on the highlighted line below
:Error 1 'BankLibrary.Record' does not contain a constructor that takes 4 arguments

// Fig. 19.8: Record.cs
// Class that represents a data record.

namespace BankLibrary
{
   public class Record
   {
      
    
      // auto-implemented LastName property
      public string LastName { get; set; }

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

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


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

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


      // parameterless constructor sets members to default values
      public Record()
         : this( 0, string.Empty, string.Empty, 0M )
      {
      } // end constructor

      // overloaded constructor sets members to parameter values
      public Record( string lastNameValue, string firstNameValue,
         string classNameValue, int iDNumberValue, string gradeNameValue)
      {
       
         
         LastName = lastNameValue;
         FirstName = firstNameValue;
         ClassName = classNameValue;
         iDNumber = iDNumberValue;
         Grade = gradeNameValue;


      } // end constructor
   } // end class Record
} // end namespace BankLibrary

Recommended Answers

All 5 Replies

Your constructor that takes arguments has 5 but your parameterless constructor is calling for a constructor that only has 4 arguments. You'll need to add one more argument in there. Once you add that you'll get another error about needing an explicit cast (why 0M and not just 0?)

This code:

// parameterless constructor sets members to default values
      public Record()
         : this( 0, string.Empty, string.Empty, 0M )
      {
      } // end constructor

Needs another parameter because the only other constructor

// overloaded constructor sets members to parameter values
      public Record( string lastNameValue, string firstNameValue,
         string classNameValue, int iDNumberValue, string gradeNameValue)
      {

Has 5 parameters. You are missing the gradeNameValue in the first code block. You are also passing invalid values (the first one is an int, but the constructor takes a string).

am still stuck

Since it is Figure 19.8 I'm going to assume it comes from a book. What does the book have to say?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.