If all your sequences consist of single-digit numbers, you can solve this by noting that all the correct sequences should be substrings of the longest such sequence, i.e. from "0123456789". Thus, the verification can be performed as follows:
bool res = "0123456789".Contains(str);
Demo on ideon.
source
share