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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:14:40+00:00 2026-06-10T21:14:40+00:00

I have a Console app with the following code: using System; namespace HeadfirstPage210bill {

  • 0

I have a Console app with the following code:

    using System;

    namespace HeadfirstPage210bill
    {
        class Program
        {
            static void Main(string[] args)
            {
                CableBill myBill = new CableBill(4);
                Console.WriteLine(myBill.iGotChanged);
                Console.WriteLine(myBill.CalculateAmount(7).ToString("£##,#0.00"));
                Console.WriteLine("Press enter to exit");
                Console.WriteLine(myBill.iGotChanged);
                Console.Read();
            }
        }
    }

The class CableBill.cs is the following:

    using System;

    namespace HeadfirstPage210bill
    {
        class CableBill
        {
            private int rentalFee;
            public CableBill(int rentalFee) {
                iGotChanged = 0;
                this.rentalFee = rentalFee;
                discount = false;
            }

            public int iGotChanged = 0;


            private int payPerViewDiscount;
            private bool discount;
            public bool Discount {
                set {
                    discount = value;
                    if (discount) {
                        payPerViewDiscount = 2;
                        iGotChanged = 1;
                    } else {
                        payPerViewDiscount = 0;
                        iGotChanged = 2;
                    }
                }
            }

            public int CalculateAmount(int payPerViewMoviesOrdered) {
                return (rentalFee - payPerViewDiscount) * payPerViewMoviesOrdered;
            }

        }
    }

The console is returning the following:

enter image description here

What I can not see is when payPerViewDiscount is set to 0. Surely this can only happen when the Discount property is set but if the property Discount is called then the variable iGotChanged should be returning 1 or 2, but it seems to stay on 0. Because it is type int is there a default value for payPerViewDiscount of 0?

  • 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-10T21:14:42+00:00Added an answer on June 10, 2026 at 9:14 pm

    yes the default value of int is 0 you can check using the default keyword

    int t = default(int);
    

    t will hold 0

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

Sidebar

Related Questions

Let's say I have the following code for a C# console app. using System;
I have reproduced my problem in a console app. Following is the code. using
I have the following code that allows my console app to go to the
I have a DLL with the following code using System.Text; using Microsoft.Win32; using System.Diagnostics;
I have the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using
I have a .exe program (console app) written in .net. I need to execute
I have a simple console app using SQL Compact 4.0 and entity frameworks 4.
I have the following projects: MVC Console application Class library Windows forms application COM
I have the following code as part of app.js and today I upgraded Express
Code to replicate In my app I have the following code. var seed =

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.