C# 字符串按设置的格试在前面或后面增加空格或其它字符
1 public string lengadd(string stringa, string stringb, int count, int mode) //以stringa的长度,未到count的长度则增加stringb,mode属性0是增加前面,1是增加后面 2 { 3 int stringaa = System.Text.Encoding.Default.GetBytes(stringa).Length; 4 if (mode == 0) 5 { 6 for (int i = 1; i <= (count - stringaa); i++) 7 { 8 stringa = stringb + stringa; 9 } 10 11 } 12 else 13 { 14 for (int i = 1; i <= (count - stringaa); i++) 15 { 16 stringa = stringa + stringb; 17 } 18 19 } 20 return stringa; 21 }
QQ:254595754
手机号:15074704856