Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perform Converting Strings to Integers

Edward Zhou
Edward Zhou
401 Points

why do you need "int runningTotal = 0" in the beginning?

why do you need "int runningTotal = 0" in the beginning? especially when the total is definitely not zero.

2 Answers

Hi, the integer variable must be set otherwise the program won't know where to start from. If you didn't have runningTotal then you wouldn't be able to add up and show the client how many minutes they've worked out for..

It's basically a container to add all the clients minutes and display it.

At the very beginning before anyone adds minutes for the first time, the total IS zero.