Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Replace() [4/4]

StringBuilder System.Text.StringBuilder.Replace ( string oldValue,
string? newValue,
int startIndex,
int count )
inline

Definition at line 1855 of file StringBuilder.cs.

1856 {
1857 int length = Length;
1858 if ((uint)startIndex > (uint)length)
1859 {
1860 throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index);
1861 }
1863 {
1864 throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_Index);
1865 }
1866 if (oldValue == null)
1867 {
1868 throw new ArgumentNullException("oldValue");
1869 }
1870 if (oldValue.Length == 0)
1871 {
1872 throw new ArgumentException(SR.Argument_EmptyName, "oldValue");
1873 }
1874 if (newValue == null)
1875 {
1876 newValue = string.Empty;
1877 }
1878 int[] array = null;
1879 int num = 0;
1881 int num2 = startIndex - stringBuilder.m_ChunkOffset;
1882 while (count > 0)
1883 {
1885 {
1886 if (array == null)
1887 {
1888 array = new int[5];
1889 }
1890 else if (num >= array.Length)
1891 {
1892 Array.Resize(ref array, array.Length * 3 / 2 + 4);
1893 }
1894 array[num++] = num2;
1895 num2 += oldValue.Length;
1896 count -= oldValue.Length;
1897 }
1898 else
1899 {
1900 num2++;
1901 count--;
1902 }
1903 if (num2 >= stringBuilder.m_ChunkLength || count == 0)
1904 {
1905 int num3 = num2 + stringBuilder.m_ChunkOffset;
1907 num3 += (newValue.Length - oldValue.Length) * num;
1908 num = 0;
1910 num2 = num3 - stringBuilder.m_ChunkOffset;
1911 }
1912 }
1913 return this;
1914 }
bool StartsWith(StringBuilder chunk, int indexInChunk, int count, string value)
StringBuilder FindChunkForIndex(int index)
unsafe void ReplaceAllInChunk(int[] replacements, int replacementsCount, StringBuilder sourceChunk, int removeCount, string value)

References System.SR.Argument_EmptyName, System.SR.ArgumentOutOfRange_Index, System.array, System.count, System.Runtime.Serialization.Dictionary, System.Text.StringBuilder.FindChunkForIndex(), System.length, System.Text.StringBuilder.Length, System.Text.StringBuilder.ReplaceAllInChunk(), System.startIndex, and System.Text.StringBuilder.StartsWith().