Deleting text from the text_field.Text on ios

AnamuUenishiAnamuUenishi USMember ✭✭
edited March 2017 in Xamarin.iOS

Right now this is my code, i am making a calculator.

if (text_field.Text == "")              //If textfield is completely blank
                //Dont do anything
            else                                                            //If the text_field is not blank
                text_field.Text = "-" + text_field.Text;                    //Add the - sign to the text_field.Text

            if (text_field.Text.Contains("-"))
                text_field.Text = text_field.Text;


I am trying to make a code for a negative and positive button. When the negative button is pressed it says -7 or -8. But i don't want a negative symbol printed if there is no number before. But if there is a number before and the negative button is pressed it will print out the negative symbol before the number. The code above can do all of that but my issue was. If the negative button is pressed again, i want it to delete the negative symbol from the text_field.Text. But this seems to not work for some issue. Can someone tell me how i could fix this issue.

Best Answer


Sign In or Register to comment.