[No000089] String (fill-in) left-justified (fill slot) right

Source: Internet
Author: User

usingSystem;namespaceChinese Chinese sort sort{Internal classProgram {/// <summary>        ///Take a substring/// </summary>        /// <param name= "Oristr" >Original String</param>        /// <param name= "Beginindex" >take the starting position of the substring</param>        /// <param name= "Len" >take the length of the substring</param>        /// <returns>Sub-string</returns>         Public StaticString subString (String oristr,intBeginindex,intLen) {            intstrlen =oristr.length; Beginindex= Beginindex-1; stringstr =NULL; if(Strlen <=beginindex) {Console.WriteLine (" out of"+ Oristr +"' s length, please recheck!"); }            Else if(strlen <= Beginindex +Len) {STR=oristr.substring (Beginindex); }            Else{str= Oristr.substring (beginindex, Beginindex +Len); }            returnstr; }        /// <summary>        ///left complement, right-aligned/// </summary>        /// <param name= "Oristr" >Original String</param>        /// <param name= "Len" >Target String length</param>        /// <param name= "Alexin" >complement character</param>        /// <returns>Target String</returns>         Public StaticString PadRight (String oristr,intLenCharalexin) {            intstrlen =oristr.length; stringstr =NULL; if(Strlen <Len) {                 for(inti =0; i < Len-strlen; i++) {str= str +Alexin; }} str= str +Oristr; returnstr; }        /// <summary>        ///right-fill, left-justified/// </summary>        /// <param name= "Oristr" >Original String</param>        /// <param name= "Len" >Target String length</param>        /// <param name= "Alexin" >complement character</param>        /// <returns>Target String</returns>         Public StaticString PadLeft (String oristr,intLenCharalexin) {            intstrlen =oristr.length; stringstr =NULL; if(Strlen <Len) {                 for(inti =0; i < Len-strlen; i++) {str= str +Alexin; }} str= Oristr +str; returnstr; }        Private Static voidMain (string[] args) {            stringStemp ="0123456789"; Console.WriteLine (Stemp.substring (0,3));//012UInt64 Uintrownum =0; UInt64 sInt= ++Uintrownum; Console.WriteLine (Sint.tostring ());//1Console.readkey (); }    }}

[No000089] String (fill-in) left-justified (fill slot) right

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.