locked
Digit sequence change inside Textbox? RRS feed

  • Question

  • User-367318540 posted

    i want to change sequence of digits in textbox ,i am getting value from Weight Machine scale in textbox like =0.52412 ,but i want result in second textbox2 like 21425.0

    Wednesday, January 22, 2020 5:38 PM

Answers

  • User281315223 posted

    Since the value in your TextBox would be a string, you simply need to reverse the string via a Reverse method:

    public static string Reverse(string s)
    {
        var characters = s.ToCharArray();
        Array.Reverse(characters);
        return new string(characters);
    }

    So you would just use this as :

    YourTextBox.Text = Reverse(YourTextBox.Text);

    Additionally, you could accomplish this through LINQ as a one-liner:

    YourTextBox.Text =  new string(YourTextBox.Text.Reverse().ToArray());



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 22, 2020 5:49 PM