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

◆ Remove() [2/2]

string System.String.Remove ( int startIndex,
int count )
inline

Definition at line 2285 of file String.cs.

2286 {
2287 if (startIndex < 0)
2288 {
2289 throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_StartIndex);
2290 }
2291 if (count < 0)
2292 {
2293 throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NegativeCount);
2294 }
2295 int length = Length;
2296 if (count > length - startIndex)
2297 {
2298 throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_IndexCount);
2299 }
2300 if (count == 0)
2301 {
2302 return this;
2303 }
2304 int num = length - count;
2305 if (num == 0)
2306 {
2307 return Empty;
2308 }
2309 string text = FastAllocateString(num);
2310 Buffer.Memmove(ref text._firstChar, ref _firstChar, (nuint)startIndex);
2311 Buffer.Memmove(ref Unsafe.Add(ref text._firstChar, startIndex), ref Unsafe.Add(ref _firstChar, startIndex + count), (nuint)(num - startIndex));
2312 return text;
2313 }
static readonly string Empty
Definition String.cs:29
char _firstChar
Definition String.cs:35
static string FastAllocateString(int length)

References System.String._firstChar, System.SR.ArgumentOutOfRange_IndexCount, System.SR.ArgumentOutOfRange_NegativeCount, System.SR.ArgumentOutOfRange_StartIndex, System.count, System.String.Empty, System.String.FastAllocateString(), System.length, System.String.Length, System.Buffer.Memmove(), System.startIndex, and System.text.