jeudi 8 juin 2017

C# simple if not working! (trying to clear line on first run)

i am trying to learn C# via lynda, and now i am trying to make a small program, i only have a simple textbox and a textblock, now i am trying to get it to clear the texkblock on first command from the textbox!

i am trying with a simple "if" but no matter what it only reeds the true part! hope you can help me and remember just starting so need to keep it simple :D

        //Void for the input!
    private void runcode1_Click(object sender, RoutedEventArgs e)
    {
        //place the runcode1_Click into a string i can read later!
        Output(input1.Text); 
    }

    //void for output!
    private void Output(string value)
    {
        //int for claring "text box 1" on first command!
        bool Tempnumer1 = true;
        if (Tempnumer1 == true)
        {
            output1.Text = "" + value + Environment.NewLine + Tempnumer1;
            Tempnumer1 = false;
        }
        if (Tempnumer1 == false)
        {
            output1.Text = value + Environment.NewLine + Tempnumer1;
        }
    }

Aucun commentaire:

Enregistrer un commentaire