Determines whether a string contains three consecutive (ascending or descending) or the same number.

Source: Internet
Author: User

Some netizens asked "How does asp.net determine that a mobile phone number string contains three consecutive characters or three identical characters ?" :



Insus. NET has done some exercises and shared the methods, hoping that netizens can learn from them.
Object-oriented: First, write a Number class to process the Number. It is a very simple class and clear at a glance.

#38 to #41 method, IsUpNumber () determines whether it is a continuous ascending number.
IsDownNumber () is used to determine whether it is a continuous descending number.
#48 to #51, IsSameNumber () is determined to be the same continuous number.
#53 to #57. AppendNumber () is the method for adding new numbers. In the method body, there is also a statistical method, which indicates the number of digits.
#64 to #93 is the override ToString () method.

Next, we need to write another class:



#21 to #33 split the string into a single character, convert it into a number, and store it in a List <T> set. Later, we will analyze and process the data from this set.
#35 to #37 is a set of three types, which are used to store continuous ascending, descending, and identical numbers.
#39 to #79 process data.
#81 to #120 is the output data.

Next let's take a look at the real-time operations. Insus. NET lists some characters. The first two are posted by netizens:

View Code


Go to. aspx. cs:



Real-time operations:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.