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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:09:28+00:00 2026-06-13T13:09:28+00:00

I am about to explode. I have been looking for two hours for a

  • 0

I am about to explode. I have been looking for two hours for a way to fix this problem. I have a switch statement in the setTimer method. When i debug the program, the timerType value changes while the method is in action, but as soon as it exits, timerType reverts back to null. This makes my case statement kind of useless as I need it to change for the next time I call the method. I would love your helping hand as I am sure it is something simple as usual 🙁 . I tried changing it to an int to see if it was something to do with the String type or whatever. Im a bit of a noob. Please stop me from floundering any longer (at least on this particular problem 🙂 )

public string timerType;



if (checkRoundChanged()) {
     SoundPlayer.Play();
     setTimer(timerType);
}

and the method

protected void setTimer(String timerType){
        switch (timerType) {
            case "ready":
                secLeft = readySec;
                minLeft = readyMin;
                timerType = "round";
                break;
            case "round":
                secLeft = roundSec;
                minLeft = roundMin;
                timerType = "rest";
                break;
            case "rest":
                secLeft = restSec;
                minLeft = restMin;
                timerType = "round";
                break;
            case "relax":
                secLeft = relaxSec;
                minLeft = relaxMin;
                timerType = "done";
                break;
            default:
                timerType = "ready";
                break;
        }

    }

Thankyou!

  • 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-13T13:09:29+00:00Added an answer on June 13, 2026 at 1:09 pm

    Strings are passed by value, not by reference. You can either return the new value:

    protected string setTimer(String timerType){
        switch (timerType) {
            case "ready":
                secLeft = readySec;
                minLeft = readyMin;
                timerType = "round";
                break;
            case "round":
                secLeft = roundSec;
                minLeft = roundMin;
                timerType = "rest";
                break;
            case "rest":
                secLeft = restSec;
                minLeft = restMin;
                timerType = "round";
                break;
            case "relax":
                secLeft = relaxSec;
                minLeft = relaxMin;
                timerType = "done";
                break;
            default:
                timerType = "ready";
                break;
        }
    
        return timerType;
    }
    
    ....
    
    timerType =  setTimer(timerType);
    

    Or pass by reference:

    protected void setTimer(ref String timerType) {
       ...
       timerType = newValue;
       ...
    }
    
    setTimer(ref timerType);
    

    Here is some recommended reading.

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

Sidebar

Related Questions

My head is about to explode after looking into why this is not working
My head is about to explode with this logic, can anyone help? Class A
I have been hearing a lot about Project Euler so I thought I solve
I have been very excited about MongoDb and have been testing it lately. I
I have been figuring about and trying to make my IRC bot send private
I have been using the Zend Framework with an MVC configuration, read about Ruby
I have been researching around trying to find the best way to begin developing
(Bear with me, I promise this gets to shebang and windows.) I have about
I know this might ma a simple question, it must have been answered before
I have been reading about Reliability Features in .NET and have written the following

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.