12345678910111213141516171819202122232425262728293031 |
- namespace TBL.CSharp.Base
- {
- public static partial class Extension
- {
- /// <summary>
- /// 将一个字符串重复 <paramref name="count"/> 次
- /// </summary>
- public static string Repeat(this string source, int count)
- {
- var result = string.Empty;
- for (var i = 0; i < count; i++)
- {
- result += source;
- }
- return result;
- }
- /// <summary>
- /// 切换首字母大小写
- /// </summary>
- public static unsafe string CaptionSwitch(this string str, bool isUpper)
- {
- if (str == null) return null;
- var ret = string.Copy(str);
- fixed (char* ptr = ret)
- *ptr = isUpper ? char.ToUpper(*ptr) : char.ToLower(*ptr);
- return ret;
- }
- }
- }
|