C # table-driven method + one-point reflection: three methods of encapsulation: "getting a specified number of random digits without repeating strings"

Source: Internet
Author: User

1. Structure

 

 

 ClassPublic class GetMethods {...}

Class variables:

 

GetStr ()
GetStrAndNum ()

 

 

 

 

 

ClassPublic class GetString {...}

Class variables:

   

 

 

Methods In the class:

 

2. Code

TheClassPublic class GetMethods {...}

: Methods in this class come from: http://www.cnblogs.com/xiachufeng/archive/2012/04/01/2429065.html

                  codeCount=           rep =                                                                  str =               num2 = DateTime.Now.Ticks +             rep++             Random random =  Random((()((()num2) & )) | (()(num2 >>              ( i = ; i < codeCount; i++                   num =                 str = str + (()( + (()(num %                                                                                 str =               num2 = DateTime.Now.Ticks +             rep++             Random random =  Random((()((()num2) & )) | (()(num2 >>              ( i = ; i < codeCount; i++                   num =                 str = str + (()( + (()(num %                                                                                 str =               num2 = DateTime.Now.Ticks +             rep++             Random random =  Random((()((()num2) & )) | (()(num2 >>              ( i = ; i < codeCount; i++                                    num =                  ((num % ) ==                       ch = ()( + (()(num %                                         ch = ()( + (()(num %                   str = str +                    }

2)CategoryPublic class GetString {...}

                              GetRandomCode(Code codeType,              GetMethods getMethod=             getMethod.codeCount =              addMethod =               ()addMethod.Invoke(getMethod,                                    GetMethods getMethod=              addMethod =               ()addMethod.Invoke(getMethod,                                  [] methods = { , ,               methods[(      }


 

3. Application

 

Using StringControl; // Code omitted
//.....................
/// Code omitted
// Usage

RandomKey = GetString. GetRandomCode (GetString. Code. StrAndNum ,);
RandomKey1 = GetString. GetRandomCode (GetString. Code. StrAndNum); // four digits
/// Code omitted
//.....................
/// Code omitted

 

4. Download

 

 

5. Summary

 

 

 

 

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.