public static string MakeInitSmall(string s, TextInfo textInfo) { #if DEBUG if (s == null) { throw new ArgumentNullException(nameof(s)); } if (textInfo == null) { throw new ArgumentNullException(nameof(textInfo)); } #endif if (s.Length == 0) { return(s); } var actualFirstLetter = s[0]; var expectedFirstLetter = textInfo.ToLower(actualFirstLetter); if (expectedFirstLetter == actualFirstLetter) { return(s); } if (s.Length == 1) { return(expectedFirstLetter.ToString()); } var builder = StringBuilderPool.Get(s, s.Length); builder[0] = expectedFirstLetter; return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string WithoutIndex(this string @this, int index) { #if DEBUG if (@this == null) { throw new ArgumentNullException(nameof(@this)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } if (index >= @this.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } #endif if (index == 0) { return(@this.Substring(1)); } var lastIndex = @this.Length - 1; if (index == lastIndex) { return(@this.Substring(0, lastIndex)); } var builder = StringBuilderPool.Get(lastIndex); builder.Append(@this, 0, index); builder.Append(@this, index + 1, lastIndex - index); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string Replace(this string @this, int index, int removeCount, string replacement) { var builder = StringBuilderPool.Get(@this, Math.Max(@this.Length, @this.Length + replacement.Length - removeCount)); builder.Replace(index, removeCount, replacement); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(string str0, int startIndex0, int count0, string str1, int startIndex1, int count1) { var builder = StringBuilderPool.Get(count0 + count1); builder.Append(str0, startIndex0, count0); builder.Append(str1, startIndex1, count1); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatSubstring(string str0, int startIndex0, int length0, char char1) { var builder = StringBuilderPool.Get(length0 + 1); builder.Append(str0, startIndex0, length0); builder.Append(char1); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(string str0, int startIndex0, int count0, string str1, string str2, int startIndex2) { var count2 = str2.Length - startIndex2; var builder = StringBuilderPool.Get(count0 + str1.Length + count2); builder.Append(str0, startIndex0, count0); builder.Append(str1); builder.Append(str2, startIndex2, count2); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatSubstring(string str0, int startIndex0, int length0, string str1, int startIndex1) { var length1 = str1.Length - startIndex1; var builder = StringBuilderPool.Get(length0 + length1); builder.Append(str0, startIndex0, length0); builder.Append(str1, startIndex1, length1); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatSubstring(string str0, int startIndex0, int length0, string str1, string str2, int startIndex2) { var length2 = str2.Length - startIndex2; var builder = StringBuilderPool.Get(length0 + str1.Length + length2); builder.Append(str0, startIndex0, length0); builder.Append(str1); builder.Append(str2, startIndex2, length2); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(string str0, int startIndex0, int count0, string str1, char char2, string str3, int startIndex3) { var count3 = str3.Length - startIndex3; var builder = StringBuilderPool.Get(count0 + str1.Length + 1 + count3); builder.Append(str0, startIndex0, count0); builder.Append(str1); builder.Append(char2); builder.Append(str3, startIndex3, count3); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatSubstring(string str0, int startIndex0, int length0, string str1, char char2, string str3, int startIndex3) { var length3 = str3.Length - startIndex3; var builder = StringBuilderPool.Get(length0 + str1.Length + 1 + length3); builder.Append(str0, startIndex0, length0); builder.Append(str1); builder.Append(char2); builder.Append(str3, startIndex3, length3); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string RemoveChars(this string @this, CharacterSet chars) { if (string.IsNullOrEmpty(@this) || chars == null || chars.IsEmpty) { return(@this); } var builder = StringBuilderPool.Get(@this); builder.RemoveChars(chars); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(string str0, string str1, int startIndex1, int count1) { if (string.IsNullOrEmpty(str0)) { return(str1.Substring(startIndex1, count1)); } var builder = StringBuilderPool.Get(str0.Length + count1); builder.Append(str0); builder.Append(str1, startIndex1, count1); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(string str0, int startIndex0, int count0, string str1) { if (count0 == 0) { return(str1 ?? string.Empty); } var builder = StringBuilderPool.Get(str1.Length + count0); builder.Append(str0, startIndex0, count0); builder.Append(str1); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string Without(this ReadOnlySpan <char> @this, char value) { var removeIndex = @this.IndexOf(value); if (removeIndex < 0) { return(@this.ToString()); } if (removeIndex == @this.Length - 1) { return(@this.Slice(0, removeIndex).ToString()); } var builder = StringBuilderPool.Get(@this.Length - 1); builder.Append(@this.Slice(0, removeIndex)); for (var i = removeIndex; i < @this.Length; i++) { ref readonly var c = ref @this[i];
public static string RemoveChars(this string @this, CharacterSet chars) { #if DEBUG if (@this == null) { throw new ArgumentNullException(nameof(@this)); } if (chars == null) { throw new ArgumentNullException(nameof(chars)); } #endif if (@this.Length == 0 || chars.IsEmpty) { return(@this); } var builder = StringBuilderPool.Get(@this); builder.RemoveChars(chars); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string MakeTitleCase(string s, TextInfo textInfo) { #if DEBUG if (s == null) { throw new ArgumentNullException(nameof(s)); } if (textInfo == null) { throw new ArgumentNullException(nameof(textInfo)); } #endif if (s.Length == 0) { return(s); } var builder = StringBuilderPool.Get(textInfo.ToLower(s)); builder[0] = textInfo.ToUpper(s[0]); return(StringBuilderPool.GetStringAndReturn(builder)); }
public static string ConcatString(this string @this, ReadOnlySpan <char> value) { #if DEBUG if (@this == null) { throw new ArgumentNullException(nameof(@this)); } #endif if (@this.Length == 0) { return(value.ToString()); } if (value.IsEmpty) { return(@this); } var builder = StringBuilderPool.Get(@this.Length + value.Length); builder.Append(@this); builder.Append(value); return(StringBuilderPool.GetStringAndReturn(builder)); }