How to compare value with the same textbox in C#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ceeblaj
    New Member
    • Jan 2015
    • 1

    How to compare value with the same textbox in C#?

    I have a text format like this:
    12-22-24-22-33-13
    when user click a button then check for duplicated number in that text.
    how to handle this in C#.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You could split the string on the "-" character.

    Then loop through the array that results from the split and look for any duplicates either by using regular expressions to search for the text/number or by looping through the results a second time (skipping the index you are currently on or taking into account that you will have at least 1 match because the item you are looking for is definitely in the string) to see if there are any others that match.


    -Frinny

    Comment

    Working...