Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
String.cs
Go to the documentation of this file.
13using System.Text;
16
17namespace System;
18
20[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
21public sealed class String : IComparable, IEnumerable, IConvertible, IEnumerable<char>, IComparable<string?>, IEquatable<string?>, ICloneable
22{
23 [StructLayout(LayoutKind.Explicit, Size = 32)]
24 private struct ProbabilisticMap
25 {
26 }
27
28 [Intrinsic]
29 public static readonly string Empty;
30
32 private readonly int _stringLength;
33
35 private char _firstChar;
36
37 [IndexerName("Chars")]
38 public char this[int index]
39 {
40 [Intrinsic]
41 get
42 {
43 if ((uint)index >= (uint)_stringLength)
44 {
46 }
47 return Unsafe.Add(ref _firstChar, (nint)(uint)index);
48 }
49 }
50
51 public int Length
52 {
53 [Intrinsic]
54 get
55 {
56 return _stringLength;
57 }
58 }
59
60 [MethodImpl(MethodImplOptions.InternalCall)]
61 internal static extern string FastAllocateString(int length);
62
63 [MethodImpl(MethodImplOptions.InternalCall)]
64 internal extern void SetTrailByte(byte data);
65
66 [MethodImpl(MethodImplOptions.InternalCall)]
67 internal extern bool TryGetTrailByte(out byte data);
68
69 [MethodImpl(MethodImplOptions.InternalCall)]
70 private extern string Intern();
71
72 [MethodImpl(MethodImplOptions.InternalCall)]
73 private extern string IsInterned();
74
75 public static string Intern(string str)
76 {
77 if ((object)str == null)
78 {
79 throw new ArgumentNullException("str");
80 }
81 return str.Intern();
82 }
83
84 public static string? IsInterned(string str)
85 {
86 if ((object)str == null)
87 {
88 throw new ArgumentNullException("str");
89 }
90 return str.IsInterned();
91 }
92
93 internal unsafe static void InternalCopy(string src, IntPtr dest, int len)
94 {
95 if (len != 0)
96 {
97 Buffer.Memmove(ref *(byte*)(void*)dest, ref Unsafe.As<char, byte>(ref src.GetRawStringData()), (nuint)len);
98 }
99 }
100
101 internal unsafe int GetBytesFromEncoding(byte* pbNativeBuffer, int cbNativeBuffer, Encoding encoding)
102 {
103 fixed (char* chars = &_firstChar)
104 {
106 }
107 }
108
109 [MethodImpl(MethodImplOptions.AggressiveInlining)]
110 private static bool EqualsHelper(string strA, string strB)
111 {
112 return SpanHelpers.SequenceEqual(ref Unsafe.As<char, byte>(ref strA.GetRawStringData()), ref Unsafe.As<char, byte>(ref strB.GetRawStringData()), (uint)(strA.Length * 2));
113 }
114
115 [MethodImpl(MethodImplOptions.AggressiveInlining)]
116 private static int CompareOrdinalHelper(string strA, int indexA, int countA, string strB, int indexB, int countB)
117 {
118 return SpanHelpers.SequenceCompareTo(ref Unsafe.Add(ref strA.GetRawStringData(), (nint)(uint)indexA), countA, ref Unsafe.Add(ref strB.GetRawStringData(), (nint)(uint)indexB), countB);
119 }
120
121 internal static bool EqualsOrdinalIgnoreCase(string strA, string strB)
122 {
123 if ((object)strA == strB)
124 {
125 return true;
126 }
127 if ((object)strA == null || (object)strB == null)
128 {
129 return false;
130 }
131 if (strA.Length != strB.Length)
132 {
133 return false;
134 }
136 }
137
138 private static bool EqualsOrdinalIgnoreCaseNoLengthCheck(string strA, string strB)
139 {
140 return Ordinal.EqualsIgnoreCase(ref strA.GetRawStringData(), ref strB.GetRawStringData(), strB.Length);
141 }
142
143 private unsafe static int CompareOrdinalHelper(string strA, string strB)
144 {
145 int num = Math.Min(strA.Length, strB.Length);
146 fixed (char* ptr = &strA._firstChar)
147 {
148 fixed (char* ptr3 = &strB._firstChar)
149 {
150 char* ptr2 = ptr;
151 char* ptr4 = ptr3;
152 if (ptr2[1] == ptr4[1])
153 {
154 num -= 2;
155 ptr2 += 2;
156 ptr4 += 2;
157 while (true)
158 {
159 if (num >= 12)
160 {
161 if (*(long*)ptr2 == *(long*)ptr4)
162 {
163 if (*(long*)(ptr2 + 4) == *(long*)(ptr4 + 4))
164 {
165 if (*(long*)(ptr2 + 8) == *(long*)(ptr4 + 8))
166 {
167 num -= 12;
168 ptr2 += 12;
169 ptr4 += 12;
170 continue;
171 }
172 ptr2 += 4;
173 ptr4 += 4;
174 }
175 ptr2 += 4;
176 ptr4 += 4;
177 }
178 if (*(int*)ptr2 == *(int*)ptr4)
179 {
180 ptr2 += 2;
181 ptr4 += 2;
182 }
183 break;
184 }
185 while (true)
186 {
187 if (num > 0)
188 {
189 if (*(int*)ptr2 != *(int*)ptr4)
190 {
191 break;
192 }
193 num -= 2;
194 ptr2 += 2;
195 ptr4 += 2;
196 continue;
197 }
198 return strA.Length - strB.Length;
199 }
200 break;
201 }
202 if (*ptr2 != *ptr4)
203 {
204 return *ptr2 - *ptr4;
205 }
206 }
207 return ptr2[1] - ptr4[1];
208 }
209 }
210 }
211
212 public static int Compare(string? strA, string? strB)
213 {
214 return Compare(strA, strB, StringComparison.CurrentCulture);
215 }
216
217 public static int Compare(string? strA, string? strB, bool ignoreCase)
218 {
219 StringComparison comparisonType = (ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture);
221 }
222
223 public static int Compare(string? strA, string? strB, StringComparison comparisonType)
224 {
225 if ((object)strA == strB)
226 {
228 return 0;
229 }
230 if ((object)strA == null)
231 {
233 return -1;
234 }
235 if ((object)strB == null)
236 {
238 return 1;
239 }
240 switch (comparisonType)
241 {
242 case StringComparison.CurrentCulture:
243 case StringComparison.CurrentCultureIgnoreCase:
245 case StringComparison.InvariantCulture:
246 case StringComparison.InvariantCultureIgnoreCase:
248 case StringComparison.Ordinal:
249 if (strA._firstChar != strB._firstChar)
250 {
251 return strA._firstChar - strB._firstChar;
252 }
254 case StringComparison.OrdinalIgnoreCase:
255 return Ordinal.CompareStringIgnoreCase(ref strA.GetRawStringData(), strA.Length, ref strB.GetRawStringData(), strB.Length);
256 default:
257 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
258 }
259 }
260
261 public static int Compare(string? strA, string? strB, CultureInfo? culture, CompareOptions options)
262 {
264 return cultureInfo.CompareInfo.Compare(strA, strB, options);
265 }
266
267 public static int Compare(string? strA, string? strB, bool ignoreCase, CultureInfo? culture)
268 {
269 CompareOptions options = (ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
270 return Compare(strA, strB, culture, options);
271 }
272
273 public static int Compare(string? strA, int indexA, string? strB, int indexB, int length)
274 {
275 return Compare(strA, indexA, strB, indexB, length, ignoreCase: false);
276 }
277
278 public static int Compare(string? strA, int indexA, string? strB, int indexB, int length, bool ignoreCase)
279 {
280 int num = length;
281 int num2 = length;
282 if ((object)strA != null)
283 {
284 num = Math.Min(num, strA.Length - indexA);
285 }
286 if ((object)strB != null)
287 {
288 num2 = Math.Min(num2, strB.Length - indexB);
289 }
290 CompareOptions options = (ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
291 return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, indexA, num, strB, indexB, num2, options);
292 }
293
294 public static int Compare(string? strA, int indexA, string? strB, int indexB, int length, bool ignoreCase, CultureInfo? culture)
295 {
296 CompareOptions options = (ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
298 }
299
300 public static int Compare(string? strA, int indexA, string? strB, int indexB, int length, CultureInfo? culture, CompareOptions options)
301 {
303 int num = length;
304 int num2 = length;
305 if ((object)strA != null)
306 {
307 num = Math.Min(num, strA.Length - indexA);
308 }
309 if ((object)strB != null)
310 {
311 num2 = Math.Min(num2, strB.Length - indexB);
312 }
313 return cultureInfo.CompareInfo.Compare(strA, indexA, num, strB, indexB, num2, options);
314 }
315
316 public static int Compare(string? strA, int indexA, string? strB, int indexB, int length, StringComparison comparisonType)
317 {
319 if ((object)strA == null || (object)strB == null)
320 {
321 if ((object)strA == strB)
322 {
323 return 0;
324 }
325 if ((object)strA != null)
326 {
327 return 1;
328 }
329 return -1;
330 }
331 if (length < 0)
332 {
334 }
335 if (indexA < 0 || indexB < 0)
336 {
337 string paramName = ((indexA < 0) ? "indexA" : "indexB");
339 }
340 if (strA.Length - indexA < 0 || strB.Length - indexB < 0)
341 {
342 string paramName2 = ((strA.Length - indexA < 0) ? "indexA" : "indexB");
344 }
345 if (length == 0 || ((object)strA == strB && indexA == indexB))
346 {
347 return 0;
348 }
349 int num = Math.Min(length, strA.Length - indexA);
350 int num2 = Math.Min(length, strB.Length - indexB);
351 switch (comparisonType)
352 {
353 case StringComparison.CurrentCulture:
354 case StringComparison.CurrentCultureIgnoreCase:
356 case StringComparison.InvariantCulture:
357 case StringComparison.InvariantCultureIgnoreCase:
359 case StringComparison.Ordinal:
361 default:
362 return Ordinal.CompareStringIgnoreCase(ref Unsafe.Add(ref strA.GetRawStringData(), indexA), num, ref Unsafe.Add(ref strB.GetRawStringData(), indexB), num2);
363 }
364 }
365
366 public static int CompareOrdinal(string? strA, string? strB)
367 {
368 if ((object)strA == strB)
369 {
370 return 0;
371 }
372 if ((object)strA == null)
373 {
374 return -1;
375 }
376 if ((object)strB == null)
377 {
378 return 1;
379 }
380 if (strA._firstChar != strB._firstChar)
381 {
382 return strA._firstChar - strB._firstChar;
383 }
385 }
386
387 [MethodImpl(MethodImplOptions.AggressiveInlining)]
389 {
390 return SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(strA), strA.Length, ref MemoryMarshal.GetReference(strB), strB.Length);
391 }
392
393 public static int CompareOrdinal(string? strA, int indexA, string? strB, int indexB, int length)
394 {
395 if ((object)strA == null || (object)strB == null)
396 {
397 if ((object)strA == strB)
398 {
399 return 0;
400 }
401 if ((object)strA != null)
402 {
403 return 1;
404 }
405 return -1;
406 }
407 if (length < 0)
408 {
410 }
411 if (indexA < 0 || indexB < 0)
412 {
413 string paramName = ((indexA < 0) ? "indexA" : "indexB");
415 }
416 int num = Math.Min(length, strA.Length - indexA);
417 int num2 = Math.Min(length, strB.Length - indexB);
418 if (num < 0 || num2 < 0)
419 {
420 string paramName2 = ((num < 0) ? "indexA" : "indexB");
422 }
423 if (length == 0 || ((object)strA == strB && indexA == indexB))
424 {
425 return 0;
426 }
428 }
429
430 public int CompareTo(object? value)
431 {
432 if (value == null)
433 {
434 return 1;
435 }
436 if (!(value is string strB))
437 {
439 }
440 return CompareTo(strB);
441 }
442
443 public int CompareTo(string? strB)
444 {
445 return Compare(this, strB, StringComparison.CurrentCulture);
446 }
447
448 public bool EndsWith(string value)
449 {
450 return EndsWith(value, StringComparison.CurrentCulture);
451 }
452
454 {
455 if ((object)value == null)
456 {
457 throw new ArgumentNullException("value");
458 }
459 if ((object)this == value)
460 {
462 return true;
463 }
464 if (value.Length == 0)
465 {
467 return true;
468 }
469 switch (comparisonType)
470 {
471 case StringComparison.CurrentCulture:
472 case StringComparison.CurrentCultureIgnoreCase:
474 case StringComparison.InvariantCulture:
475 case StringComparison.InvariantCultureIgnoreCase:
477 case StringComparison.Ordinal:
478 {
479 int num = Length - value.Length;
480 if ((uint)num <= (uint)Length)
481 {
482 return this.AsSpan(num).SequenceEqual(value);
483 }
484 return false;
485 }
486 case StringComparison.OrdinalIgnoreCase:
487 if (Length >= value.Length)
488 {
489 return Ordinal.CompareStringIgnoreCase(ref Unsafe.Add(ref GetRawStringData(), Length - value.Length), value.Length, ref value.GetRawStringData(), value.Length) == 0;
490 }
491 return false;
492 default:
493 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
494 }
495 }
496
497 public bool EndsWith(string value, bool ignoreCase, CultureInfo? culture)
498 {
499 if ((object)value == null)
500 {
501 throw new ArgumentNullException("value");
502 }
503 if ((object)this == value)
504 {
505 return true;
506 }
508 return cultureInfo.CompareInfo.IsSuffix(this, value, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
509 }
510
511 public bool EndsWith(char value)
512 {
513 int num = Length - 1;
514 if ((uint)num < (uint)Length)
515 {
516 return this[num] == value;
517 }
518 return false;
519 }
520
521 public override bool Equals([NotNullWhen(true)] object? obj)
522 {
523 if (this == obj)
524 {
525 return true;
526 }
527 if (!(obj is string text))
528 {
529 return false;
530 }
531 if (Length != text.Length)
532 {
533 return false;
534 }
535 return EqualsHelper(this, text);
536 }
537
538 public bool Equals([NotNullWhen(true)] string? value)
539 {
540 if ((object)this == value)
541 {
542 return true;
543 }
544 if ((object)value == null)
545 {
546 return false;
547 }
548 if (Length != value.Length)
549 {
550 return false;
551 }
552 return EqualsHelper(this, value);
553 }
554
556 {
557 if ((object)this == value)
558 {
560 return true;
561 }
562 if ((object)value == null)
563 {
565 return false;
566 }
567 switch (comparisonType)
568 {
569 case StringComparison.CurrentCulture:
570 case StringComparison.CurrentCultureIgnoreCase:
572 case StringComparison.InvariantCulture:
573 case StringComparison.InvariantCultureIgnoreCase:
575 case StringComparison.Ordinal:
576 if (Length != value.Length)
577 {
578 return false;
579 }
580 return EqualsHelper(this, value);
581 case StringComparison.OrdinalIgnoreCase:
582 if (Length != value.Length)
583 {
584 return false;
585 }
587 default:
588 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
589 }
590 }
591
592 public static bool Equals(string? a, string? b)
593 {
594 if ((object)a == b)
595 {
596 return true;
597 }
598 if ((object)a == null || (object)b == null || a.Length != b.Length)
599 {
600 return false;
601 }
602 return EqualsHelper(a, b);
603 }
604
605 public static bool Equals(string? a, string? b, StringComparison comparisonType)
606 {
607 if ((object)a == b)
608 {
610 return true;
611 }
612 if ((object)a == null || (object)b == null)
613 {
615 return false;
616 }
617 switch (comparisonType)
618 {
619 case StringComparison.CurrentCulture:
620 case StringComparison.CurrentCultureIgnoreCase:
622 case StringComparison.InvariantCulture:
623 case StringComparison.InvariantCultureIgnoreCase:
625 case StringComparison.Ordinal:
626 if (a.Length != b.Length)
627 {
628 return false;
629 }
630 return EqualsHelper(a, b);
631 case StringComparison.OrdinalIgnoreCase:
632 if (a.Length != b.Length)
633 {
634 return false;
635 }
637 default:
638 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
639 }
640 }
641
642 public static bool operator ==(string? a, string? b)
643 {
644 return Equals(a, b);
645 }
646
647 public static bool operator !=(string? a, string? b)
648 {
649 return !Equals(a, b);
650 }
651
652 [MethodImpl(MethodImplOptions.AggressiveInlining)]
653 public override int GetHashCode()
654 {
656 return Marvin.ComputeHash32(ref Unsafe.As<char, byte>(ref _firstChar), (uint)(_stringLength * 2), (uint)defaultSeed, (uint)(defaultSeed >> 32));
657 }
658
660 {
661 return StringComparer.FromComparison(comparisonType).GetHashCode(this);
662 }
663
664 [MethodImpl(MethodImplOptions.AggressiveInlining)]
670
671 [MethodImpl(MethodImplOptions.AggressiveInlining)]
673 {
675 return Marvin.ComputeHash32(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value)), (uint)(value.Length * 2), (uint)defaultSeed, (uint)(defaultSeed >> 32));
676 }
677
679 {
680 switch (comparisonType)
681 {
682 case StringComparison.CurrentCulture:
683 case StringComparison.CurrentCultureIgnoreCase:
685 case StringComparison.InvariantCulture:
686 case StringComparison.InvariantCultureIgnoreCase:
688 case StringComparison.Ordinal:
689 return GetHashCode(value);
690 case StringComparison.OrdinalIgnoreCase:
692 default:
693 ThrowHelper.ThrowArgumentException(ExceptionResource.NotSupported_StringComparison, ExceptionArgument.comparisonType);
694 return 0;
695 }
696 }
697
698 [MethodImpl(MethodImplOptions.AggressiveInlining)]
700 {
702 return Marvin.ComputeHash32OrdinalIgnoreCase(ref MemoryMarshal.GetReference(value), value.Length, (uint)defaultSeed, (uint)(defaultSeed >> 32));
703 }
704
705 internal unsafe int GetNonRandomizedHashCode()
706 {
707 fixed (char* ptr = &_firstChar)
708 {
709 uint num = 352654597u;
710 uint num2 = num;
711 uint* ptr2 = (uint*)ptr;
712 int num3 = Length;
713 while (num3 > 2)
714 {
715 num3 -= 4;
716 num = (BitOperations.RotateLeft(num, 5) + num) ^ *ptr2;
717 num2 = (BitOperations.RotateLeft(num2, 5) + num2) ^ ptr2[1];
718 ptr2 += 2;
719 }
720 if (num3 > 0)
721 {
723 }
724 return (int)(num + num2 * 1566083941);
725 }
726 }
727
729 {
730 uint num = 352654597u;
731 uint num2 = num;
732 fixed (char* ptr = &_firstChar)
733 {
734 uint* ptr2 = (uint*)ptr;
735 int num3 = Length;
736 while (true)
737 {
738 if (num3 > 2)
739 {
740 uint num4 = *ptr2;
741 uint num5 = ptr2[1];
743 {
744 num3 -= 4;
745 num = (BitOperations.RotateLeft(num, 5) + num) ^ (num4 | 0x200020u);
747 ptr2 += 2;
748 continue;
749 }
750 }
751 else
752 {
753 if (num3 <= 0)
754 {
755 break;
756 }
757 uint num6 = *ptr2;
759 {
761 break;
762 }
763 }
764 goto end_IL_0011;
765 }
766 goto IL_00a1;
768 }
770 IL_00a1:
771 return (int)(num + num2 * 1566083941);
772 unsafe static int GetNonRandomizedHashCodeOrdinalIgnoreCaseSlow(string str)
773 {
774 int num7 = str.Length;
775 char[] array = null;
776 Span<char> span = (((uint)num7 >= 64u) ? ((Span<char>)(array = ArrayPool<char>.Shared.Rent(num7 + 1))) : stackalloc char[64]);
779 destination[num7] = '\0';
780 uint num9 = 352654597u;
781 uint num10 = num9;
782 fixed (char* ptr3 = destination)
783 {
784 uint* ptr4 = (uint*)ptr3;
785 while (num7 > 2)
786 {
787 num7 -= 4;
790 ptr4 += 2;
791 }
792 if (num7 > 0)
793 {
795 }
796 }
797 if (array != null)
798 {
799 ArrayPool<char>.Shared.Return(array);
800 }
801 return (int)(num9 + num10 * 1566083941);
802 }
803 }
804
805 public bool StartsWith(string value)
806 {
807 if ((object)value == null)
808 {
809 throw new ArgumentNullException("value");
810 }
811 return StartsWith(value, StringComparison.CurrentCulture);
812 }
813
815 {
816 if ((object)value == null)
817 {
818 throw new ArgumentNullException("value");
819 }
820 if ((object)this == value)
821 {
823 return true;
824 }
825 if (value.Length == 0)
826 {
828 return true;
829 }
830 switch (comparisonType)
831 {
832 case StringComparison.CurrentCulture:
833 case StringComparison.CurrentCultureIgnoreCase:
835 case StringComparison.InvariantCulture:
836 case StringComparison.InvariantCultureIgnoreCase:
838 case StringComparison.Ordinal:
839 if (Length < value.Length || _firstChar != value._firstChar)
840 {
841 return false;
842 }
843 if (value.Length != 1)
844 {
845 return SpanHelpers.SequenceEqual(ref Unsafe.As<char, byte>(ref GetRawStringData()), ref Unsafe.As<char, byte>(ref value.GetRawStringData()), (nuint)value.Length * (nuint)2u);
846 }
847 return true;
848 case StringComparison.OrdinalIgnoreCase:
849 if (Length < value.Length)
850 {
851 return false;
852 }
853 return Ordinal.EqualsIgnoreCase(ref GetRawStringData(), ref value.GetRawStringData(), value.Length);
854 default:
855 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
856 }
857 }
858
859 public bool StartsWith(string value, bool ignoreCase, CultureInfo? culture)
860 {
861 if ((object)value == null)
862 {
863 throw new ArgumentNullException("value");
864 }
865 if ((object)this == value)
866 {
867 return true;
868 }
870 return cultureInfo.CompareInfo.IsPrefix(this, value, ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None);
871 }
872
873 public bool StartsWith(char value)
874 {
875 if (Length != 0)
876 {
877 return _firstChar == value;
878 }
879 return false;
880 }
881
883 {
884 if ((uint)comparisonType > 5u)
885 {
886 ThrowHelper.ThrowArgumentException(ExceptionResource.NotSupported_StringComparison, ExceptionArgument.comparisonType);
887 }
888 }
889
894
899
900 [MethodImpl(MethodImplOptions.InternalCall)]
901 [DynamicDependency("Ctor(System.Char[])")]
902 public extern String(char[]? value);
903
904 private string Ctor(char[] value)
905 {
906 if (value == null || value.Length == 0)
907 {
908 return Empty;
909 }
910 string text = FastAllocateString(value.Length);
911 nuint elementCount = (uint)text.Length;
913 return text;
914 }
915
916 [MethodImpl(MethodImplOptions.InternalCall)]
917 [DynamicDependency("Ctor(System.Char[],System.Int32,System.Int32)")]
918 public extern String(char[] value, int startIndex, int length);
919
920 private string Ctor(char[] value, int startIndex, int length)
921 {
922 if (value == null)
923 {
924 throw new ArgumentNullException("value");
925 }
926 if (startIndex < 0)
927 {
929 }
930 if (length < 0)
931 {
933 }
934 if (startIndex > value.Length - length)
935 {
937 }
938 if (length == 0)
939 {
940 return Empty;
941 }
943 nuint elementCount = (uint)text.Length;
945 return text;
946 }
947
948 [MethodImpl(MethodImplOptions.InternalCall)]
949 [CLSCompliant(false)]
950 [DynamicDependency("Ctor(System.Char*)")]
951 public unsafe extern String(char* value);
952
953 private unsafe string Ctor(char* ptr)
954 {
955 if (ptr == null)
956 {
957 return Empty;
958 }
959 int num = wcslen(ptr);
960 if (num == 0)
961 {
962 return Empty;
963 }
964 string text = FastAllocateString(num);
965 nuint elementCount = (uint)text.Length;
966 Buffer.Memmove(ref text._firstChar, ref *ptr, elementCount);
967 return text;
968 }
969
970 [MethodImpl(MethodImplOptions.InternalCall)]
971 [CLSCompliant(false)]
972 [DynamicDependency("Ctor(System.Char*,System.Int32,System.Int32)")]
973 public unsafe extern String(char* value, int startIndex, int length);
974
975 private unsafe string Ctor(char* ptr, int startIndex, int length)
976 {
977 if (length < 0)
978 {
980 }
981 if (startIndex < 0)
982 {
984 }
985 char* ptr2 = ptr + startIndex;
986 if (ptr2 < ptr)
987 {
989 }
990 if (length == 0)
991 {
992 return Empty;
993 }
994 if (ptr == null)
995 {
997 }
999 nuint elementCount = (uint)text.Length;
1000 Buffer.Memmove(ref text._firstChar, ref *ptr2, elementCount);
1001 return text;
1002 }
1003
1004 [MethodImpl(MethodImplOptions.InternalCall)]
1005 [CLSCompliant(false)]
1006 [DynamicDependency("Ctor(System.SByte*)")]
1007 public unsafe extern String(sbyte* value);
1008
1009 private unsafe string Ctor(sbyte* value)
1010 {
1011 if (value == null)
1012 {
1013 return Empty;
1014 }
1015 int numBytes = strlen((byte*)value);
1017 }
1018
1019 [MethodImpl(MethodImplOptions.InternalCall)]
1020 [CLSCompliant(false)]
1021 [DynamicDependency("Ctor(System.SByte*,System.Int32,System.Int32)")]
1022 public unsafe extern String(sbyte* value, int startIndex, int length);
1023
1024 private unsafe string Ctor(sbyte* value, int startIndex, int length)
1025 {
1026 if (startIndex < 0)
1027 {
1029 }
1030 if (length < 0)
1031 {
1033 }
1034 if (value == null)
1035 {
1036 if (length == 0)
1037 {
1038 return Empty;
1039 }
1040 throw new ArgumentNullException("value");
1041 }
1042 byte* ptr = (byte*)(value + startIndex);
1043 if (ptr < value)
1044 {
1046 }
1048 }
1049
1050 private unsafe static string CreateStringForSByteConstructor(byte* pb, int numBytes)
1051 {
1052 if (numBytes == 0)
1053 {
1054 return Empty;
1055 }
1056 int num = Interop.Kernel32.MultiByteToWideChar(0u, 1u, pb, numBytes, null, 0);
1057 if (num == 0)
1058 {
1060 }
1061 string text = FastAllocateString(num);
1062 fixed (char* lpWideCharStr = &text._firstChar)
1063 {
1065 }
1066 if (num == 0)
1067 {
1069 }
1070 return text;
1071 }
1072
1073 [MethodImpl(MethodImplOptions.InternalCall)]
1074 [CLSCompliant(false)]
1075 [DynamicDependency("Ctor(System.SByte*,System.Int32,System.Int32,System.Text.Encoding)")]
1076 public unsafe extern String(sbyte* value, int startIndex, int length, Encoding enc);
1077
1078 private unsafe string Ctor(sbyte* value, int startIndex, int length, Encoding enc)
1079 {
1080 if (enc == null)
1081 {
1082 return new string(value, startIndex, length);
1083 }
1084 if (length < 0)
1085 {
1087 }
1088 if (startIndex < 0)
1089 {
1091 }
1092 if (value == null)
1093 {
1094 if (length == 0)
1095 {
1096 return Empty;
1097 }
1098 throw new ArgumentNullException("value");
1099 }
1100 byte* ptr = (byte*)(value + startIndex);
1101 if (ptr < value)
1102 {
1104 }
1105 return enc.GetString(new ReadOnlySpan<byte>(ptr, length));
1106 }
1107
1108 [MethodImpl(MethodImplOptions.InternalCall)]
1109 [DynamicDependency("Ctor(System.Char,System.Int32)")]
1110 public extern String(char c, int count);
1111
1112 private unsafe string Ctor(char c, int count)
1113 {
1114 if (count <= 0)
1115 {
1116 if (count == 0)
1117 {
1118 return Empty;
1119 }
1121 }
1122 string text = FastAllocateString(count);
1123 if (c != 0)
1124 {
1125 fixed (char* ptr = &text._firstChar)
1126 {
1127 uint num = ((uint)c << 16) | c;
1128 uint* ptr2 = (uint*)ptr;
1129 if (count >= 4)
1130 {
1131 count -= 4;
1132 do
1133 {
1134 *ptr2 = num;
1135 ptr2[1] = num;
1136 ptr2 += 2;
1137 count -= 4;
1138 }
1139 while (count >= 0);
1140 }
1141 if (((uint)count & 2u) != 0)
1142 {
1143 *ptr2 = num;
1144 ptr2++;
1145 }
1146 if (((uint)count & (true ? 1u : 0u)) != 0)
1147 {
1148 *(char*)ptr2 = c;
1149 }
1150 }
1151 }
1152 return text;
1153 }
1154
1155 [MethodImpl(MethodImplOptions.InternalCall)]
1156 [DynamicDependency("Ctor(System.ReadOnlySpan{System.Char})")]
1158
1160 {
1161 if (value.Length == 0)
1162 {
1163 return Empty;
1164 }
1165 string text = FastAllocateString(value.Length);
1166 Buffer.Memmove(ref text._firstChar, ref MemoryMarshal.GetReference(value), (uint)value.Length);
1167 return text;
1168 }
1169
1170 public static string Create<TState>(int length, TState state, SpanAction<char, TState> action)
1171 {
1172 if (action == null)
1173 {
1174 throw new ArgumentNullException("action");
1175 }
1176 if (length <= 0)
1177 {
1178 if (length == 0)
1179 {
1180 return Empty;
1181 }
1182 throw new ArgumentOutOfRangeException("length");
1183 }
1184 string text = FastAllocateString(length);
1185 action(new Span<char>(ref text.GetRawStringData(), length), state);
1186 return text;
1187 }
1188
1190 {
1191 return handler.ToStringAndClear();
1192 }
1193
1194 public static string Create(IFormatProvider? provider, Span<char> initialBuffer, [InterpolatedStringHandlerArgument(new string[] { "provider", "initialBuffer" })] ref DefaultInterpolatedStringHandler handler)
1195 {
1196 return handler.ToStringAndClear();
1197 }
1198
1199 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1200 public static implicit operator ReadOnlySpan<char>(string? value)
1201 {
1202 if ((object)value == null)
1203 {
1204 return default(ReadOnlySpan<char>);
1205 }
1206 return new ReadOnlySpan<char>(ref value.GetRawStringData(), value.Length);
1207 }
1208
1209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1211 {
1212 if ((ulong)((long)(uint)startIndex + (long)(uint)count) > (ulong)(uint)Length)
1213 {
1214 slice = default(ReadOnlySpan<char>);
1215 return false;
1216 }
1217 slice = new ReadOnlySpan<char>(ref Unsafe.Add(ref _firstChar, (nint)(uint)startIndex), count);
1218 return true;
1219 }
1220
1221 public object Clone()
1222 {
1223 return this;
1224 }
1225
1226 public static string Copy(string str)
1227 {
1228 if ((object)str == null)
1229 {
1230 throw new ArgumentNullException("str");
1231 }
1232 string text = FastAllocateString(str.Length);
1233 nuint elementCount = (uint)text.Length;
1234 Buffer.Memmove(ref text._firstChar, ref str._firstChar, elementCount);
1235 return text;
1236 }
1237
1238 public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
1239 {
1240 if (destination == null)
1241 {
1242 throw new ArgumentNullException("destination");
1243 }
1244 if (count < 0)
1245 {
1247 }
1248 if (sourceIndex < 0)
1249 {
1251 }
1252 if (count > Length - sourceIndex)
1253 {
1255 }
1256 if (destinationIndex > destination.Length - count || destinationIndex < 0)
1257 {
1258 throw new ArgumentOutOfRangeException("destinationIndex", SR.ArgumentOutOfRange_IndexCount);
1259 }
1261 }
1262
1263 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1265 {
1266 if ((uint)Length <= (uint)destination.Length)
1267 {
1268 Buffer.Memmove(ref destination._pointer.Value, ref _firstChar, (uint)Length);
1269 }
1270 else
1271 {
1273 }
1274 }
1275
1276 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1278 {
1279 bool result = false;
1280 if ((uint)Length <= (uint)destination.Length)
1281 {
1282 Buffer.Memmove(ref destination._pointer.Value, ref _firstChar, (uint)Length);
1283 result = true;
1284 }
1285 return result;
1286 }
1287
1288 public char[] ToCharArray()
1289 {
1290 if (Length == 0)
1291 {
1292 return Array.Empty<char>();
1293 }
1294 char[] array = new char[Length];
1296 return array;
1297 }
1298
1299 public char[] ToCharArray(int startIndex, int length)
1300 {
1302 {
1304 }
1305 if (length <= 0)
1306 {
1307 if (length == 0)
1308 {
1309 return Array.Empty<char>();
1310 }
1312 }
1313 char[] array = new char[length];
1315 return array;
1316 }
1317
1319 public static bool IsNullOrEmpty([NotNullWhen(false)] string? value)
1320 {
1321 if ((object)value != null && value.Length != 0)
1322 {
1323 return false;
1324 }
1325 return true;
1326 }
1327
1328 public static bool IsNullOrWhiteSpace([NotNullWhen(false)] string? value)
1329 {
1330 if ((object)value == null)
1331 {
1332 return true;
1333 }
1334 for (int i = 0; i < value.Length; i++)
1335 {
1336 if (!char.IsWhiteSpace(value[i]))
1337 {
1338 return false;
1339 }
1340 }
1341 return true;
1342 }
1343
1346 public ref readonly char GetPinnableReference()
1347 {
1348 return ref _firstChar;
1349 }
1350
1351 internal ref char GetRawStringData()
1352 {
1353 return ref _firstChar;
1354 }
1355
1356 internal unsafe static string CreateStringFromEncoding(byte* bytes, int byteLength, Encoding encoding)
1357 {
1358 int charCount = encoding.GetCharCount(bytes, byteLength);
1359 if (charCount == 0)
1360 {
1361 return Empty;
1362 }
1364 fixed (char* chars = &text._firstChar)
1365 {
1366 int chars2 = encoding.GetChars(bytes, byteLength, chars, charCount);
1367 }
1368 return text;
1369 }
1370
1371 internal static string CreateFromChar(char c)
1372 {
1373 string text = FastAllocateString(1);
1374 text._firstChar = c;
1375 return text;
1376 }
1377
1378 internal static string CreateFromChar(char c1, char c2)
1379 {
1380 string text = FastAllocateString(2);
1381 text._firstChar = c1;
1382 Unsafe.Add(ref text._firstChar, 1) = c2;
1383 return text;
1384 }
1385
1386 public override string ToString()
1387 {
1388 return this;
1389 }
1390
1392 {
1393 return this;
1394 }
1395
1397 {
1398 return new CharEnumerator(this);
1399 }
1400
1402 {
1403 return new CharEnumerator(this);
1404 }
1405
1407 {
1408 return new CharEnumerator(this);
1409 }
1410
1412 {
1413 return new StringRuneEnumerator(this);
1414 }
1415
1416 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1417 internal unsafe static int wcslen(char* ptr)
1418 {
1419 int num = SpanHelpers.IndexOf(ref *ptr, '\0', int.MaxValue);
1420 if (num < 0)
1421 {
1423 }
1424 return num;
1425 }
1426
1427 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1428 internal unsafe static int strlen(byte* ptr)
1429 {
1430 int num = SpanHelpers.IndexOf(ref *ptr, 0, int.MaxValue);
1431 if (num < 0)
1432 {
1434 }
1435 return num;
1436 }
1437
1440 {
1442 }
1443
1445 {
1446 return TypeCode.String;
1447 }
1448
1453
1455 {
1456 return Convert.ToChar(this, provider);
1457 }
1458
1460 {
1461 return Convert.ToSByte(this, provider);
1462 }
1463
1465 {
1466 return Convert.ToByte(this, provider);
1467 }
1468
1470 {
1471 return Convert.ToInt16(this, provider);
1472 }
1473
1475 {
1476 return Convert.ToUInt16(this, provider);
1477 }
1478
1480 {
1481 return Convert.ToInt32(this, provider);
1482 }
1483
1485 {
1486 return Convert.ToUInt32(this, provider);
1487 }
1488
1490 {
1491 return Convert.ToInt64(this, provider);
1492 }
1493
1495 {
1496 return Convert.ToUInt64(this, provider);
1497 }
1498
1500 {
1501 return Convert.ToSingle(this, provider);
1502 }
1503
1505 {
1506 return Convert.ToDouble(this, provider);
1507 }
1508
1510 {
1511 return Convert.ToDecimal(this, provider);
1512 }
1513
1518
1523
1524 public bool IsNormalized()
1525 {
1526 return IsNormalized(NormalizationForm.FormC);
1527 }
1528
1530 {
1532 {
1533 return true;
1534 }
1536 }
1537
1538 public string Normalize()
1539 {
1540 return Normalize(NormalizationForm.FormC);
1541 }
1542
1544 {
1546 {
1547 return this;
1548 }
1550 }
1551
1552 private unsafe bool IsAscii()
1553 {
1554 fixed (char* pBuffer = &_firstChar)
1555 {
1556 return ASCIIUtility.GetIndexOfFirstNonAsciiChar(pBuffer, (uint)Length) == (uint)Length;
1557 }
1558 }
1559
1560 private static void FillStringChecked(string dest, int destPos, string src)
1561 {
1562 if (src.Length > dest.Length - destPos)
1563 {
1564 throw new IndexOutOfRangeException();
1565 }
1566 Buffer.Memmove(ref Unsafe.Add(ref dest._firstChar, destPos), ref src._firstChar, (uint)src.Length);
1567 }
1568
1569 public static string Concat(object? arg0)
1570 {
1571 return arg0?.ToString() ?? Empty;
1572 }
1573
1574 public static string Concat(object? arg0, object? arg1)
1575 {
1576 return arg0?.ToString() + arg1;
1577 }
1578
1579 public static string Concat(object? arg0, object? arg1, object? arg2)
1580 {
1581 return arg0?.ToString() + arg1?.ToString() + arg2;
1582 }
1583
1584 public static string Concat(params object?[] args)
1585 {
1586 if (args == null)
1587 {
1588 throw new ArgumentNullException("args");
1589 }
1590 if (args.Length <= 1)
1591 {
1592 object obj;
1593 if (args.Length != 0)
1594 {
1595 obj = args[0]?.ToString();
1596 if (obj == null)
1597 {
1598 return Empty;
1599 }
1600 }
1601 else
1602 {
1603 obj = Empty;
1604 }
1605 return (string)obj;
1606 }
1607 string[] array = new string[args.Length];
1608 int num = 0;
1609 for (int i = 0; i < args.Length; i++)
1610 {
1611 num += (array[i] = args[i]?.ToString() ?? Empty).Length;
1612 if (num < 0)
1613 {
1614 throw new OutOfMemoryException();
1615 }
1616 }
1617 if (num == 0)
1618 {
1619 return Empty;
1620 }
1621 string text = FastAllocateString(num);
1622 int num2 = 0;
1623 foreach (string text2 in array)
1624 {
1626 num2 += text2.Length;
1627 }
1628 return text;
1629 }
1630
1631 public static string Concat<T>(IEnumerable<T> values)
1632 {
1633 if (values == null)
1634 {
1635 throw new ArgumentNullException("values");
1636 }
1637 if (typeof(T) == typeof(char))
1638 {
1640 {
1641 if (!enumerator.MoveNext())
1642 {
1643 return Empty;
1644 }
1645 char current = enumerator.Current;
1646 if (!enumerator.MoveNext())
1647 {
1648 return CreateFromChar(current);
1649 }
1652 valueStringBuilder.Append(current);
1653 do
1654 {
1655 current = enumerator.Current;
1656 valueStringBuilder.Append(current);
1657 }
1658 while (enumerator.MoveNext());
1659 return valueStringBuilder.ToString();
1660 }
1661 }
1663 if (!enumerator2.MoveNext())
1664 {
1665 return Empty;
1666 }
1667 string text = enumerator2.Current?.ToString();
1668 if (!enumerator2.MoveNext())
1669 {
1670 return text ?? Empty;
1671 }
1674 valueStringBuilder2.Append(text);
1675 do
1676 {
1677 T current2 = enumerator2.Current;
1678 if (current2 != null)
1679 {
1680 valueStringBuilder2.Append(current2.ToString());
1681 }
1682 }
1683 while (enumerator2.MoveNext());
1684 return valueStringBuilder2.ToString();
1685 }
1686
1687 public static string Concat(IEnumerable<string?> values)
1688 {
1689 if (values == null)
1690 {
1691 throw new ArgumentNullException("values");
1692 }
1693 using IEnumerator<string> enumerator = values.GetEnumerator();
1694 if (!enumerator.MoveNext())
1695 {
1696 return Empty;
1697 }
1698 string current = enumerator.Current;
1699 if (!enumerator.MoveNext())
1700 {
1701 return current ?? Empty;
1702 }
1705 valueStringBuilder.Append(current);
1706 do
1707 {
1708 valueStringBuilder.Append(enumerator.Current);
1709 }
1710 while (enumerator.MoveNext());
1711 return valueStringBuilder.ToString();
1712 }
1713
1714 public static string Concat(string? str0, string? str1)
1715 {
1716 if (IsNullOrEmpty(str0))
1717 {
1718 if (IsNullOrEmpty(str1))
1719 {
1720 return Empty;
1721 }
1722 return str1;
1723 }
1724 if (IsNullOrEmpty(str1))
1725 {
1726 return str0;
1727 }
1728 int length = str0.Length;
1729 string text = FastAllocateString(length + str1.Length);
1732 return text;
1733 }
1734
1735 public static string Concat(string? str0, string? str1, string? str2)
1736 {
1737 if (IsNullOrEmpty(str0))
1738 {
1739 return str1 + str2;
1740 }
1741 if (IsNullOrEmpty(str1))
1742 {
1743 return str0 + str2;
1744 }
1745 if (IsNullOrEmpty(str2))
1746 {
1747 return str0 + str1;
1748 }
1749 int length = str0.Length + str1.Length + str2.Length;
1750 string text = FastAllocateString(length);
1752 FillStringChecked(text, str0.Length, str1);
1753 FillStringChecked(text, str0.Length + str1.Length, str2);
1754 return text;
1755 }
1756
1757 public static string Concat(string? str0, string? str1, string? str2, string? str3)
1758 {
1759 if (IsNullOrEmpty(str0))
1760 {
1761 return str1 + str2 + str3;
1762 }
1763 if (IsNullOrEmpty(str1))
1764 {
1765 return str0 + str2 + str3;
1766 }
1767 if (IsNullOrEmpty(str2))
1768 {
1769 return str0 + str1 + str3;
1770 }
1771 if (IsNullOrEmpty(str3))
1772 {
1773 return str0 + str1 + str2;
1774 }
1775 int length = str0.Length + str1.Length + str2.Length + str3.Length;
1776 string text = FastAllocateString(length);
1778 FillStringChecked(text, str0.Length, str1);
1779 FillStringChecked(text, str0.Length + str1.Length, str2);
1780 FillStringChecked(text, str0.Length + str1.Length + str2.Length, str3);
1781 return text;
1782 }
1783
1785 {
1786 int num = checked(str0.Length + str1.Length);
1787 if (num == 0)
1788 {
1789 return Empty;
1790 }
1791 string text = FastAllocateString(num);
1792 Span<char> destination = new Span<char>(ref text._firstChar, text.Length);
1794 str1.CopyTo(destination.Slice(str0.Length));
1795 return text;
1796 }
1797
1799 {
1800 int num = checked(str0.Length + str1.Length + str2.Length);
1801 if (num == 0)
1802 {
1803 return Empty;
1804 }
1805 string text = FastAllocateString(num);
1806 Span<char> destination = new Span<char>(ref text._firstChar, text.Length);
1808 destination = destination.Slice(str0.Length);
1810 destination = destination.Slice(str1.Length);
1812 return text;
1813 }
1814
1816 {
1817 int num = checked(str0.Length + str1.Length + str2.Length + str3.Length);
1818 if (num == 0)
1819 {
1820 return Empty;
1821 }
1822 string text = FastAllocateString(num);
1823 Span<char> destination = new Span<char>(ref text._firstChar, text.Length);
1825 destination = destination.Slice(str0.Length);
1827 destination = destination.Slice(str1.Length);
1829 destination = destination.Slice(str2.Length);
1831 return text;
1832 }
1833
1834 public static string Concat(params string?[] values)
1835 {
1836 if (values == null)
1837 {
1838 throw new ArgumentNullException("values");
1839 }
1840 if (values.Length <= 1)
1841 {
1842 object obj;
1843 if (values.Length != 0)
1844 {
1845 obj = values[0];
1846 if (obj == null)
1847 {
1848 return Empty;
1849 }
1850 }
1851 else
1852 {
1853 obj = Empty;
1854 }
1855 return (string)obj;
1856 }
1857 long num = 0L;
1858 foreach (string text in values)
1859 {
1860 if ((object)text != null)
1861 {
1862 num += text.Length;
1863 }
1864 }
1865 if (num > int.MaxValue)
1866 {
1867 throw new OutOfMemoryException();
1868 }
1869 int num2 = (int)num;
1870 if (num2 == 0)
1871 {
1872 return Empty;
1873 }
1874 string text2 = FastAllocateString(num2);
1875 int num3 = 0;
1876 foreach (string text3 in values)
1877 {
1878 if (!IsNullOrEmpty(text3))
1879 {
1880 int length = text3.Length;
1881 if (length > num2 - num3)
1882 {
1883 num3 = -1;
1884 break;
1885 }
1887 num3 += length;
1888 }
1889 }
1890 if (num3 != num2)
1891 {
1892 return Concat((string[])values.Clone());
1893 }
1894 return text2;
1895 }
1896
1897 public static string Format(string format, object? arg0)
1898 {
1899 return FormatHelper(null, format, new ParamsArray(arg0));
1900 }
1901
1902 public static string Format(string format, object? arg0, object? arg1)
1903 {
1904 return FormatHelper(null, format, new ParamsArray(arg0, arg1));
1905 }
1906
1907 public static string Format(string format, object? arg0, object? arg1, object? arg2)
1908 {
1909 return FormatHelper(null, format, new ParamsArray(arg0, arg1, arg2));
1910 }
1911
1912 public static string Format(string format, params object?[] args)
1913 {
1914 if (args == null)
1915 {
1916 throw new ArgumentNullException(((object)format == null) ? "format" : "args");
1917 }
1918 return FormatHelper(null, format, new ParamsArray(args));
1919 }
1920
1921 public static string Format(IFormatProvider? provider, string format, object? arg0)
1922 {
1924 }
1925
1926 public static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1)
1927 {
1929 }
1930
1931 public static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2)
1932 {
1934 }
1935
1936 public static string Format(IFormatProvider? provider, string format, params object?[] args)
1937 {
1938 if (args == null)
1939 {
1940 throw new ArgumentNullException(((object)format == null) ? "format" : "args");
1941 }
1943 }
1944
1946 {
1947 if ((object)format == null)
1948 {
1949 throw new ArgumentNullException("format");
1950 }
1953 valueStringBuilder.EnsureCapacity(format.Length + args.Length * 8);
1954 valueStringBuilder.AppendFormatHelper(provider, format, args);
1955 return valueStringBuilder.ToString();
1956 }
1957
1958 public string Insert(int startIndex, string value)
1959 {
1960 if ((object)value == null)
1961 {
1962 throw new ArgumentNullException("value");
1963 }
1964 if ((uint)startIndex > Length)
1965 {
1966 throw new ArgumentOutOfRangeException("startIndex");
1967 }
1968 int length = Length;
1969 int length2 = value.Length;
1970 if (length == 0)
1971 {
1972 return value;
1973 }
1974 if (length2 == 0)
1975 {
1976 return this;
1977 }
1978 int length3 = length + length2;
1980 Buffer.Memmove(ref text._firstChar, ref _firstChar, (nuint)startIndex);
1981 Buffer.Memmove(ref Unsafe.Add(ref text._firstChar, startIndex), ref value._firstChar, (nuint)length2);
1983 return text;
1984 }
1985
1986 public static string Join(char separator, params string?[] value)
1987 {
1988 if (value == null)
1989 {
1991 }
1992 return JoinCore(MemoryMarshal.CreateReadOnlySpan(ref separator, 1), new ReadOnlySpan<string>(value));
1993 }
1994
1995 public static string Join(string? separator, params string?[] value)
1996 {
1997 if (value == null)
1998 {
2000 }
2001 return JoinCore(separator.AsSpan(), new ReadOnlySpan<string>(value));
2002 }
2003
2004 public static string Join(char separator, string?[] value, int startIndex, int count)
2005 {
2006 return JoinCore(MemoryMarshal.CreateReadOnlySpan(ref separator, 1), value, startIndex, count);
2007 }
2008
2009 public static string Join(string? separator, string?[] value, int startIndex, int count)
2010 {
2011 return JoinCore(separator.AsSpan(), value, startIndex, count);
2012 }
2013
2014 private static string JoinCore(ReadOnlySpan<char> separator, string[] value, int startIndex, int count)
2015 {
2016 if (value == null)
2017 {
2018 throw new ArgumentNullException("value");
2019 }
2020 if (startIndex < 0)
2021 {
2023 }
2024 if (count < 0)
2025 {
2027 }
2028 if (startIndex > value.Length - count)
2029 {
2031 }
2033 }
2034
2035 public static string Join(string? separator, IEnumerable<string?> values)
2036 {
2038 {
2039 return JoinCore(separator.AsSpan(), CollectionsMarshal.AsSpan(list));
2040 }
2041 if (values is string[] array)
2042 {
2043 return JoinCore(separator.AsSpan(), new ReadOnlySpan<string>(array));
2044 }
2045 if (values == null)
2046 {
2048 }
2049 using IEnumerator<string> enumerator = values.GetEnumerator();
2050 if (!enumerator.MoveNext())
2051 {
2052 return Empty;
2053 }
2054 string current = enumerator.Current;
2055 if (!enumerator.MoveNext())
2056 {
2057 return current ?? Empty;
2058 }
2061 valueStringBuilder.Append(current);
2062 do
2063 {
2065 valueStringBuilder.Append(enumerator.Current);
2066 }
2067 while (enumerator.MoveNext());
2068 return valueStringBuilder.ToString();
2069 }
2070
2071 public static string Join(char separator, params object?[] values)
2072 {
2073 return JoinCore(MemoryMarshal.CreateReadOnlySpan(ref separator, 1), values);
2074 }
2075
2076 public static string Join(string? separator, params object?[] values)
2077 {
2078 return JoinCore(separator.AsSpan(), values);
2079 }
2080
2081 private static string JoinCore(ReadOnlySpan<char> separator, object[] values)
2082 {
2083 if (values == null)
2084 {
2086 }
2087 if (values.Length == 0)
2088 {
2089 return Empty;
2090 }
2091 string text = values[0]?.ToString();
2092 if (values.Length == 1)
2093 {
2094 return text ?? Empty;
2095 }
2098 valueStringBuilder.Append(text);
2099 for (int i = 1; i < values.Length; i++)
2100 {
2102 object obj = values[i];
2103 if (obj != null)
2104 {
2105 valueStringBuilder.Append(obj.ToString());
2106 }
2107 }
2108 return valueStringBuilder.ToString();
2109 }
2110
2111 public static string Join<T>(char separator, IEnumerable<T> values)
2112 {
2113 return JoinCore(MemoryMarshal.CreateReadOnlySpan(ref separator, 1), values);
2114 }
2115
2116 public static string Join<T>(string? separator, IEnumerable<T> values)
2117 {
2118 return JoinCore(separator.AsSpan(), values);
2119 }
2120
2122 {
2123 if (typeof(T) == typeof(string))
2124 {
2126 {
2127 return JoinCore(separator, CollectionsMarshal.AsSpan(list));
2128 }
2129 if (values is string[] array)
2130 {
2132 }
2133 }
2134 if (values == null)
2135 {
2137 }
2139 if (!enumerator.MoveNext())
2140 {
2141 return Empty;
2142 }
2143 string text = enumerator.Current?.ToString();
2144 if (!enumerator.MoveNext())
2145 {
2146 return text ?? Empty;
2147 }
2150 valueStringBuilder.Append(text);
2151 do
2152 {
2153 T current = enumerator.Current;
2155 if (current != null)
2156 {
2157 valueStringBuilder.Append(current.ToString());
2158 }
2159 }
2160 while (enumerator.MoveNext());
2161 return valueStringBuilder.ToString();
2162 }
2163
2165 {
2166 if (values.Length <= 1)
2167 {
2168 object obj;
2169 if (!values.IsEmpty)
2170 {
2171 obj = values[0];
2172 if (obj == null)
2173 {
2174 return Empty;
2175 }
2176 }
2177 else
2178 {
2179 obj = Empty;
2180 }
2181 return (string)obj;
2182 }
2183 long num = (long)(values.Length - 1) * (long)separator.Length;
2184 if (num > int.MaxValue)
2185 {
2187 }
2188 int num2 = (int)num;
2190 for (int i = 0; i < readOnlySpan.Length; i++)
2191 {
2192 string text = readOnlySpan[i];
2193 if ((object)text != null)
2194 {
2195 num2 += text.Length;
2196 if (num2 < 0)
2197 {
2199 }
2200 }
2201 }
2202 string text2 = FastAllocateString(num2);
2203 int num3 = 0;
2204 for (int j = 0; j < values.Length; j++)
2205 {
2206 string text3 = values[j];
2207 if ((object)text3 != null)
2208 {
2209 int length = text3.Length;
2210 if (length > num2 - num3)
2211 {
2212 num3 = -1;
2213 break;
2214 }
2216 num3 += length;
2217 }
2218 if (j < values.Length - 1)
2219 {
2220 ref char reference = ref Unsafe.Add(ref text2._firstChar, num3);
2221 if (separator.Length == 1)
2222 {
2223 reference = separator[0];
2224 }
2225 else
2226 {
2228 }
2229 num3 += separator.Length;
2230 }
2231 }
2232 if (num3 != num2)
2233 {
2234 return JoinCore(separator, values.ToArray().AsSpan());
2235 }
2236 return text2;
2237 }
2238
2239 public string PadLeft(int totalWidth)
2240 {
2241 return PadLeft(totalWidth, ' ');
2242 }
2243
2244 public string PadLeft(int totalWidth, char paddingChar)
2245 {
2246 if (totalWidth < 0)
2247 {
2249 }
2250 int length = Length;
2251 int num = totalWidth - length;
2252 if (num <= 0)
2253 {
2254 return this;
2255 }
2256 string text = FastAllocateString(totalWidth);
2257 new Span<char>(ref text._firstChar, num).Fill(paddingChar);
2258 Buffer.Memmove(ref Unsafe.Add(ref text._firstChar, num), ref _firstChar, (nuint)length);
2259 return text;
2260 }
2261
2262 public string PadRight(int totalWidth)
2263 {
2264 return PadRight(totalWidth, ' ');
2265 }
2266
2267 public string PadRight(int totalWidth, char paddingChar)
2268 {
2269 if (totalWidth < 0)
2270 {
2272 }
2273 int length = Length;
2274 int num = totalWidth - length;
2275 if (num <= 0)
2276 {
2277 return this;
2278 }
2279 string text = FastAllocateString(totalWidth);
2280 Buffer.Memmove(ref text._firstChar, ref _firstChar, (nuint)length);
2281 new Span<char>(ref Unsafe.Add(ref text._firstChar, length), num).Fill(paddingChar);
2282 return text;
2283 }
2284
2285 public string Remove(int startIndex, int count)
2286 {
2287 if (startIndex < 0)
2288 {
2290 }
2291 if (count < 0)
2292 {
2294 }
2295 int length = Length;
2296 if (count > length - startIndex)
2297 {
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 }
2314
2315 public string Remove(int startIndex)
2316 {
2317 if ((uint)startIndex > Length)
2318 {
2320 }
2321 return Substring(0, startIndex);
2322 }
2323
2324 public string Replace(string oldValue, string? newValue, bool ignoreCase, CultureInfo? culture)
2325 {
2327 }
2328
2330 {
2331 switch (comparisonType)
2332 {
2333 case StringComparison.CurrentCulture:
2334 case StringComparison.CurrentCultureIgnoreCase:
2336 case StringComparison.InvariantCulture:
2337 case StringComparison.InvariantCultureIgnoreCase:
2339 case StringComparison.Ordinal:
2340 return Replace(oldValue, newValue);
2341 case StringComparison.OrdinalIgnoreCase:
2342 return ReplaceCore(oldValue, newValue, CompareInfo.Invariant, CompareOptions.OrdinalIgnoreCase);
2343 default:
2344 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
2345 }
2346 }
2347
2349 {
2350 if ((object)oldValue == null)
2351 {
2352 throw new ArgumentNullException("oldValue");
2353 }
2354 if (oldValue.Length == 0)
2355 {
2356 throw new ArgumentException(SR.Argument_StringZeroLength, "oldValue");
2357 }
2358 return ReplaceCore(this, oldValue.AsSpan(), newValue.AsSpan(), ci ?? CultureInfo.CurrentCulture.CompareInfo, options) ?? this;
2359 }
2360
2362 {
2366 bool flag = false;
2367 while (true)
2368 {
2369 int matchLength;
2370 int num = compareInfo.IndexOf(searchSpace, oldValue, options, out matchLength);
2371 if (num < 0 || matchLength == 0)
2372 {
2373 break;
2374 }
2375 valueStringBuilder.Append(searchSpace.Slice(0, num));
2377 searchSpace = searchSpace.Slice(num + matchLength);
2378 flag = true;
2379 }
2380 if (!flag)
2381 {
2382 valueStringBuilder.Dispose();
2383 return null;
2384 }
2386 return valueStringBuilder.ToString();
2387 }
2388
2389 public string Replace(char oldChar, char newChar)
2390 {
2391 if (oldChar == newChar)
2392 {
2393 return this;
2394 }
2395 int num = IndexOf(oldChar);
2396 if (num < 0)
2397 {
2398 return this;
2399 }
2400 int num2 = Length - num;
2401 string text = FastAllocateString(Length);
2402 int num3 = num;
2403 if (num3 > 0)
2404 {
2405 Buffer.Memmove(ref text._firstChar, ref _firstChar, (uint)num3);
2406 }
2407 ref ushort reference = ref Unsafe.Add(ref Unsafe.As<char, ushort>(ref _firstChar), num3);
2408 ref ushort reference2 = ref Unsafe.Add(ref Unsafe.As<char, ushort>(ref text._firstChar), num3);
2410 {
2413 do
2414 {
2415 Vector<ushort> vector = Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<ushort, byte>(ref reference));
2416 Vector<ushort> condition = Vector.Equals(vector, right);
2418 Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref reference2), value);
2422 }
2423 while (num2 >= Vector<ushort>.Count);
2424 }
2425 while (num2 > 0)
2426 {
2427 ushort num4 = reference;
2428 reference2 = ((num4 == oldChar) ? newChar : num4);
2429 reference = ref Unsafe.Add(ref reference, 1);
2431 num2--;
2432 }
2433 return text;
2434 }
2435
2436 public string Replace(string oldValue, string? newValue)
2437 {
2438 if ((object)oldValue == null)
2439 {
2440 throw new ArgumentNullException("oldValue");
2441 }
2442 if (oldValue.Length == 0)
2443 {
2444 throw new ArgumentException(SR.Argument_StringZeroLength, "oldValue");
2445 }
2446 if ((object)newValue == null)
2447 {
2448 newValue = Empty;
2449 }
2450 Span<int> initialSpan = stackalloc int[128];
2452 if (oldValue.Length == 1)
2453 {
2454 if (newValue.Length == 1)
2455 {
2456 return Replace(oldValue[0], newValue[0]);
2457 }
2458 char value = oldValue[0];
2459 int num = 0;
2460 while (true)
2461 {
2462 int num2 = SpanHelpers.IndexOf(ref Unsafe.Add(ref _firstChar, num), value, Length - num);
2463 if (num2 == -1)
2464 {
2465 break;
2466 }
2467 valueListBuilder.Append(num + num2);
2468 num += num2 + 1;
2469 }
2470 }
2471 else
2472 {
2473 int num3 = 0;
2474 while (true)
2475 {
2476 int num4 = SpanHelpers.IndexOf(ref Unsafe.Add(ref _firstChar, num3), Length - num3, ref oldValue._firstChar, oldValue.Length);
2477 if (num4 == -1)
2478 {
2479 break;
2480 }
2481 valueListBuilder.Append(num3 + num4);
2482 num3 += num4 + oldValue.Length;
2483 }
2484 }
2485 if (valueListBuilder.Length == 0)
2486 {
2487 return this;
2488 }
2489 string result = ReplaceHelper(oldValue.Length, newValue, valueListBuilder.AsSpan());
2490 valueListBuilder.Dispose();
2491 return result;
2492 }
2493
2495 {
2496 long num = Length + (long)(newValue.Length - oldValueLength) * (long)indices.Length;
2497 if (num > int.MaxValue)
2498 {
2499 throw new OutOfMemoryException();
2500 }
2501 string text = FastAllocateString((int)num);
2502 Span<char> span = new Span<char>(ref text._firstChar, text.Length);
2503 int num2 = 0;
2504 int num3 = 0;
2505 for (int i = 0; i < indices.Length; i++)
2506 {
2507 int num4 = indices[i];
2508 int num5 = num4 - num2;
2509 if (num5 != 0)
2510 {
2511 this.AsSpan(num2, num5).CopyTo(span.Slice(num3));
2512 num3 += num5;
2513 }
2515 newValue.CopyTo(span.Slice(num3));
2516 num3 += newValue.Length;
2517 }
2518 this.AsSpan(num2).CopyTo(span.Slice(num3));
2519 return text;
2520 }
2521
2522 public string ReplaceLineEndings()
2523 {
2524 return ReplaceLineEndings("\r\n");
2525 }
2526
2528 {
2529 if ((object)replacementText == null)
2530 {
2531 throw new ArgumentNullException("replacementText");
2532 }
2533 int stride;
2534 int num = IndexOfNewlineChar(this, out stride);
2535 if (num < 0)
2536 {
2537 return this;
2538 }
2539 ReadOnlySpan<char> readOnlySpan = this.AsSpan(0, num);
2540 ReadOnlySpan<char> readOnlySpan2 = this.AsSpan(num + stride);
2543 while (true)
2544 {
2546 if (num2 < 0)
2547 {
2548 break;
2549 }
2551 valueStringBuilder.Append(readOnlySpan2.Slice(0, num2));
2553 }
2555 valueStringBuilder.Dispose();
2556 return result;
2557 }
2558
2560 {
2561 stride = 0;
2562 int num = text.IndexOfAny("\r\n\f\u0085\u2028\u2029");
2563 if ((uint)num < (uint)text.Length)
2564 {
2565 stride = 1;
2566 if (text[num] == '\r')
2567 {
2568 int num2 = num + 1;
2569 if ((uint)num2 < (uint)text.Length && text[num2] == '\n')
2570 {
2571 stride = 2;
2572 }
2573 }
2574 }
2575 return num;
2576 }
2577
2579 {
2580 return SplitInternal(new ReadOnlySpan<char>(ref separator, 1), int.MaxValue, options);
2581 }
2582
2584 {
2586 }
2587
2588 public string[] Split(params char[]? separator)
2589 {
2590 return SplitInternal(separator, int.MaxValue, StringSplitOptions.None);
2591 }
2592
2593 public string[] Split(char[]? separator, int count)
2594 {
2596 }
2597
2598 public string[] Split(char[]? separator, StringSplitOptions options)
2599 {
2600 return SplitInternal(separator, int.MaxValue, options);
2601 }
2602
2603 public string[] Split(char[]? separator, int count, StringSplitOptions options)
2604 {
2606 }
2607
2609 {
2610 if (count < 0)
2611 {
2613 }
2617 while (true)
2618 {
2619 if (count <= 1 || Length == 0)
2620 {
2621 string text = this;
2622 if ((options & StringSplitOptions.TrimEntries) != 0 && count > 0)
2623 {
2624 text = text.Trim();
2625 }
2626 if ((options & StringSplitOptions.RemoveEmptyEntries) != 0 && text.Length == 0)
2627 {
2628 count = 0;
2629 }
2630 if (count != 0)
2631 {
2632 return new string[1] { text };
2633 }
2634 return Array.Empty<string>();
2635 }
2636 if (separators.IsEmpty)
2637 {
2638 options &= ~StringSplitOptions.TrimEntries;
2639 }
2640 Span<int> initialSpan = stackalloc int[128];
2643 sepList = sepListBuilder.AsSpan();
2644 if (sepList.Length != 0)
2645 {
2646 break;
2647 }
2648 count = 1;
2649 }
2651 sepListBuilder.Dispose();
2652 return result;
2653 }
2654
2656 {
2657 return SplitInternal(separator ?? Empty, null, int.MaxValue, options);
2658 }
2659
2661 {
2662 return SplitInternal(separator ?? Empty, null, count, options);
2663 }
2664
2665 public string[] Split(string[]? separator, StringSplitOptions options)
2666 {
2667 return SplitInternal(null, separator, int.MaxValue, options);
2668 }
2669
2670 public string[] Split(string[]? separator, int count, StringSplitOptions options)
2671 {
2672 return SplitInternal(null, separator, count, options);
2673 }
2674
2675 private string[] SplitInternal(string separator, string[] separators, int count, StringSplitOptions options)
2676 {
2677 if (count < 0)
2678 {
2680 }
2682 bool flag = (object)separator != null;
2683 if (!flag && (separators == null || separators.Length == 0))
2684 {
2685 return SplitInternal(default(ReadOnlySpan<char>), count, options);
2686 }
2687 while (true)
2688 {
2689 if (count <= 1 || Length == 0)
2690 {
2691 string text = this;
2692 if ((options & StringSplitOptions.TrimEntries) != 0 && count > 0)
2693 {
2694 text = text.Trim();
2695 }
2696 if ((options & StringSplitOptions.RemoveEmptyEntries) != 0 && text.Length == 0)
2697 {
2698 count = 0;
2699 }
2700 if (count != 0)
2701 {
2702 return new string[1] { text };
2703 }
2704 return Array.Empty<string>();
2705 }
2706 if (!flag)
2707 {
2708 break;
2709 }
2710 if (separator.Length == 0)
2711 {
2712 count = 1;
2713 continue;
2714 }
2716 }
2717 Span<int> initialSpan = stackalloc int[128];
2719 initialSpan = stackalloc int[128];
2724 if (sepList.Length == 0)
2725 {
2726 return new string[1] { this };
2727 }
2729 sepListBuilder.Dispose();
2730 lengthListBuilder.Dispose();
2731 return result;
2732 }
2733
2735 {
2736 Span<int> initialSpan = stackalloc int[128];
2740 if (sepList.Length == 0)
2741 {
2742 string text = this;
2743 if ((options & StringSplitOptions.TrimEntries) != 0)
2744 {
2745 text = text.Trim();
2746 }
2747 if (text.Length != 0 || (options & StringSplitOptions.RemoveEmptyEntries) == 0)
2748 {
2749 return new string[1] { text };
2750 }
2751 return Array.Empty<string>();
2752 }
2754 sepListBuilder.Dispose();
2755 return result;
2756 }
2757
2759 {
2760 int num = 0;
2761 int num2 = 0;
2762 count--;
2763 int num3 = ((sepList.Length < count) ? sepList.Length : count);
2764 string[] array = new string[num3 + 1];
2765 for (int i = 0; i < num3; i++)
2766 {
2767 if (num >= Length)
2768 {
2769 break;
2770 }
2771 array[num2++] = Substring(num, sepList[i] - num);
2772 num = sepList[i] + (lengthList.IsEmpty ? defaultLength : lengthList[i]);
2773 }
2775 {
2776 array[num2] = Substring(num);
2777 }
2778 else if (num2 == num3)
2779 {
2780 array[num2] = Empty;
2781 }
2782 return array;
2783 }
2784
2786 {
2787 int length = sepList.Length;
2788 int num = ((length < count) ? (length + 1) : count);
2789 string[] array = new string[num];
2790 int num2 = 0;
2791 int num3 = 0;
2793 for (int i = 0; i < length; i++)
2794 {
2795 span = this.AsSpan(num2, sepList[i] - num2);
2796 if ((options & StringSplitOptions.TrimEntries) != 0)
2797 {
2798 span = span.Trim();
2799 }
2800 if (!span.IsEmpty || (options & StringSplitOptions.RemoveEmptyEntries) == 0)
2801 {
2802 array[num3++] = span.ToString();
2803 }
2804 num2 = sepList[i] + (lengthList.IsEmpty ? defaultLength : lengthList[i]);
2805 if (num3 != count - 1)
2806 {
2807 continue;
2808 }
2809 if ((options & StringSplitOptions.RemoveEmptyEntries) == 0)
2810 {
2811 break;
2812 }
2813 while (++i < length)
2814 {
2815 span = this.AsSpan(num2, sepList[i] - num2);
2816 if ((options & StringSplitOptions.TrimEntries) != 0)
2817 {
2818 span = span.Trim();
2819 }
2820 if (!span.IsEmpty)
2821 {
2822 break;
2823 }
2824 num2 = sepList[i] + (lengthList.IsEmpty ? defaultLength : lengthList[i]);
2825 }
2826 break;
2827 }
2828 span = this.AsSpan(num2);
2829 if ((options & StringSplitOptions.TrimEntries) != 0)
2830 {
2831 span = span.Trim();
2832 }
2833 if (!span.IsEmpty || (options & StringSplitOptions.RemoveEmptyEntries) == 0)
2834 {
2835 array[num3++] = span.ToString();
2836 }
2837 Array.Resize(ref array, num3);
2838 return array;
2839 }
2840
2842 {
2843 if (separators.Length == 0)
2844 {
2845 for (int i = 0; i < Length; i++)
2846 {
2847 if (char.IsWhiteSpace(this[i]))
2848 {
2849 sepListBuilder.Append(i);
2850 }
2851 }
2852 return;
2853 }
2854 if (separators.Length <= 3)
2855 {
2856 char c = separators[0];
2857 char c2 = ((separators.Length > 1) ? separators[1] : c);
2858 char c3 = ((separators.Length > 2) ? separators[2] : c2);
2859 if (Length >= 16 && Sse41.IsSupported)
2860 {
2862 return;
2863 }
2864 for (int j = 0; j < Length; j++)
2865 {
2866 char c4 = this[j];
2867 if (c4 == c || c4 == c2 || c4 == c3)
2868 {
2869 sepListBuilder.Append(j);
2870 }
2871 }
2872 return;
2873 }
2875 uint* charMap = (uint*)(&probabilisticMap);
2877 for (int k = 0; k < Length; k++)
2878 {
2879 char c5 = this[k];
2880 if (IsCharBitSet(charMap, (byte)c5) && IsCharBitSet(charMap, (byte)((int)c5 >> 8)) && separators.Contains(c5))
2881 {
2882 sepListBuilder.Append(k);
2883 }
2884 }
2885 }
2886
2888 {
2889 if (!Sse41.IsSupported)
2890 {
2892 }
2893 Vector128<byte> mask = Vector128.Create(0, 2, 4, 6, 8, 10, 12, 14, byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
2897 ref char reference = ref MemoryMarshal.GetReference(this.AsSpan());
2898 int num = Length & -Vector128<ushort>.Count;
2899 int i;
2901 {
2906 if (Sse41.TestZ(right4, right4))
2907 {
2908 continue;
2909 }
2910 Vector128<byte> value = Sse2.ShiftRightLogical(right4.AsUInt64(), 4).AsByte();
2912 uint num2 = Sse2.ConvertToUInt32(value.AsUInt32());
2913 value = Sse2.ShiftRightLogical(value.AsUInt64(), 32).AsByte();
2914 uint num3 = Sse2.ConvertToUInt32(value.AsUInt32());
2915 int num4 = i;
2916 while (num2 != 0)
2917 {
2918 if ((num2 & 0xFu) != 0)
2919 {
2920 sepListBuilder.Append(num4);
2921 }
2922 num2 >>= 8;
2923 num4++;
2924 }
2925 int num5 = i + 4;
2926 while (num3 != 0)
2927 {
2928 if ((num3 & 0xFu) != 0)
2929 {
2930 sepListBuilder.Append(num5);
2931 }
2932 num3 >>= 8;
2933 num5++;
2934 }
2935 }
2936 for (; i < Length; i++)
2937 {
2938 char c4 = Unsafe.Add(ref reference, (IntPtr)(uint)i);
2939 if (c4 == c || c4 == c2 || c4 == c3)
2940 {
2941 sepListBuilder.Append(i);
2942 }
2943 }
2944 static Vector128<ushort> ReadVector(ref char c0, int offset)
2945 {
2946 return Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref c0, (IntPtr)(uint)offset)));
2947 }
2948 }
2949
2951 {
2952 int length = separator.Length;
2953 for (int i = 0; i < Length; i++)
2954 {
2955 if (this[i] == separator[0] && length <= Length - i && (length == 1 || this.AsSpan(i, length).SequenceEqual(separator)))
2956 {
2957 sepListBuilder.Append(i);
2958 i += length - 1;
2959 }
2960 }
2961 }
2962
2964 {
2965 for (int i = 0; i < Length; i++)
2966 {
2967 foreach (string text in separators)
2968 {
2969 if (!IsNullOrEmpty(text))
2970 {
2971 int length = text.Length;
2972 if (this[i] == text[0] && length <= Length - i && (length == 1 || this.AsSpan(i, length).SequenceEqual(text)))
2973 {
2974 sepListBuilder.Append(i);
2975 lengthListBuilder.Append(length);
2976 i += length - 1;
2977 break;
2978 }
2979 }
2980 }
2981 }
2982 }
2983
2985 {
2986 if (((uint)options & 0xFFFFFFFCu) != 0)
2987 {
2989 }
2990 }
2991
2992 public string Substring(int startIndex)
2993 {
2995 }
2996
2997 public string Substring(int startIndex, int length)
2998 {
2999 if (startIndex < 0)
3000 {
3002 }
3003 if (startIndex > Length)
3004 {
3006 }
3007 if (length < 0)
3008 {
3010 }
3011 if (startIndex > Length - length)
3012 {
3014 }
3015 if (length == 0)
3016 {
3017 return Empty;
3018 }
3019 if (startIndex == 0 && length == Length)
3020 {
3021 return this;
3022 }
3024 }
3025
3026 private string InternalSubString(int startIndex, int length)
3027 {
3028 string text = FastAllocateString(length);
3029 nuint elementCount = (uint)text.Length;
3030 Buffer.Memmove(ref text._firstChar, ref Unsafe.Add(ref _firstChar, (nint)(uint)startIndex), elementCount);
3031 return text;
3032 }
3033
3034 public string ToLower()
3035 {
3036 return ToLower(null);
3037 }
3038
3040 {
3042 return cultureInfo.TextInfo.ToLower(this);
3043 }
3044
3045 public string ToLowerInvariant()
3046 {
3047 return TextInfo.Invariant.ToLower(this);
3048 }
3049
3050 public string ToUpper()
3051 {
3052 return ToUpper(null);
3053 }
3054
3056 {
3058 return cultureInfo.TextInfo.ToUpper(this);
3059 }
3060
3061 public string ToUpperInvariant()
3062 {
3063 return TextInfo.Invariant.ToUpper(this);
3064 }
3065
3066 public string Trim()
3067 {
3068 return TrimWhiteSpaceHelper(TrimType.Both);
3069 }
3070
3071 public unsafe string Trim(char trimChar)
3072 {
3073 return TrimHelper(&trimChar, 1, TrimType.Both);
3074 }
3075
3076 public unsafe string Trim(params char[]? trimChars)
3077 {
3078 if (trimChars == null || trimChars.Length == 0)
3079 {
3080 return TrimWhiteSpaceHelper(TrimType.Both);
3081 }
3082 fixed (char* trimChars2 = &trimChars[0])
3083 {
3084 return TrimHelper(trimChars2, trimChars.Length, TrimType.Both);
3085 }
3086 }
3087
3088 public string TrimStart()
3089 {
3090 return TrimWhiteSpaceHelper(TrimType.Head);
3091 }
3092
3093 public unsafe string TrimStart(char trimChar)
3094 {
3095 return TrimHelper(&trimChar, 1, TrimType.Head);
3096 }
3097
3098 public unsafe string TrimStart(params char[]? trimChars)
3099 {
3100 if (trimChars == null || trimChars.Length == 0)
3101 {
3102 return TrimWhiteSpaceHelper(TrimType.Head);
3103 }
3104 fixed (char* trimChars2 = &trimChars[0])
3105 {
3106 return TrimHelper(trimChars2, trimChars.Length, TrimType.Head);
3107 }
3108 }
3109
3110 public string TrimEnd()
3111 {
3112 return TrimWhiteSpaceHelper(TrimType.Tail);
3113 }
3114
3115 public unsafe string TrimEnd(char trimChar)
3116 {
3117 return TrimHelper(&trimChar, 1, TrimType.Tail);
3118 }
3119
3120 public unsafe string TrimEnd(params char[]? trimChars)
3121 {
3122 if (trimChars == null || trimChars.Length == 0)
3123 {
3124 return TrimWhiteSpaceHelper(TrimType.Tail);
3125 }
3126 fixed (char* trimChars2 = &trimChars[0])
3127 {
3128 return TrimHelper(trimChars2, trimChars.Length, TrimType.Tail);
3129 }
3130 }
3131
3133 {
3134 int num = Length - 1;
3135 int i = 0;
3136 if ((trimType & TrimType.Head) != 0)
3137 {
3138 for (i = 0; i < Length && char.IsWhiteSpace(this[i]); i++)
3139 {
3140 }
3141 }
3142 if ((trimType & TrimType.Tail) != 0)
3143 {
3144 num = Length - 1;
3145 while (num >= i && char.IsWhiteSpace(this[num]))
3146 {
3147 num--;
3148 }
3149 }
3150 return CreateTrimmedString(i, num);
3151 }
3152
3153 private unsafe string TrimHelper(char* trimChars, int trimCharsLength, TrimType trimType)
3154 {
3155 int num = Length - 1;
3156 int i = 0;
3157 if ((trimType & TrimType.Head) != 0)
3158 {
3159 for (i = 0; i < Length; i++)
3160 {
3161 int num2 = 0;
3162 char c = this[i];
3163 for (num2 = 0; num2 < trimCharsLength && trimChars[num2] != c; num2++)
3164 {
3165 }
3166 if (num2 == trimCharsLength)
3167 {
3168 break;
3169 }
3170 }
3171 }
3172 if ((trimType & TrimType.Tail) != 0)
3173 {
3174 for (num = Length - 1; num >= i; num--)
3175 {
3176 int num3 = 0;
3177 char c2 = this[num];
3178 for (num3 = 0; num3 < trimCharsLength && trimChars[num3] != c2; num3++)
3179 {
3180 }
3181 if (num3 == trimCharsLength)
3182 {
3183 break;
3184 }
3185 }
3186 }
3187 return CreateTrimmedString(i, num);
3188 }
3189
3190 private string CreateTrimmedString(int start, int end)
3191 {
3192 int num = end - start + 1;
3193 if (num != Length)
3194 {
3195 if (num != 0)
3196 {
3197 return InternalSubString(start, num);
3198 }
3199 return Empty;
3200 }
3201 return this;
3202 }
3203
3204 public bool Contains(string value)
3205 {
3206 if ((object)value == null)
3207 {
3209 }
3210 return SpanHelpers.IndexOf(ref _firstChar, Length, ref value._firstChar, value.Length) >= 0;
3211 }
3212
3214 {
3215 return IndexOf(value, comparisonType) >= 0;
3216 }
3217
3218 public bool Contains(char value)
3219 {
3221 }
3222
3224 {
3225 return IndexOf(value, comparisonType) != -1;
3226 }
3227
3228 public int IndexOf(char value)
3229 {
3231 }
3232
3233 public int IndexOf(char value, int startIndex)
3234 {
3236 }
3237
3239 {
3240 switch (comparisonType)
3241 {
3242 case StringComparison.CurrentCulture:
3243 case StringComparison.CurrentCultureIgnoreCase:
3245 case StringComparison.InvariantCulture:
3246 case StringComparison.InvariantCultureIgnoreCase:
3248 case StringComparison.Ordinal:
3249 return IndexOf(value);
3250 case StringComparison.OrdinalIgnoreCase:
3251 return CompareInfo.Invariant.IndexOf(this, value, CompareOptions.OrdinalIgnoreCase);
3252 default:
3253 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
3254 }
3255 }
3256
3257 public int IndexOf(char value, int startIndex, int count)
3258 {
3259 if ((uint)startIndex > (uint)Length)
3260 {
3262 }
3263 if ((uint)count > (uint)(Length - startIndex))
3264 {
3266 }
3268 if (num != -1)
3269 {
3270 return num + startIndex;
3271 }
3272 return num;
3273 }
3274
3275 public int IndexOfAny(char[] anyOf)
3276 {
3277 return IndexOfAny(anyOf, 0, Length);
3278 }
3279
3280 public int IndexOfAny(char[] anyOf, int startIndex)
3281 {
3283 }
3284
3285 public int IndexOfAny(char[] anyOf, int startIndex, int count)
3286 {
3287 if (anyOf == null)
3288 {
3289 throw new ArgumentNullException("anyOf");
3290 }
3291 if ((uint)startIndex > (uint)Length)
3292 {
3294 }
3295 if ((uint)count > (uint)(Length - startIndex))
3296 {
3298 }
3299 if (anyOf.Length != 0 && anyOf.Length <= 5)
3300 {
3301 int num = new ReadOnlySpan<char>(ref Unsafe.Add(ref _firstChar, startIndex), count).IndexOfAny(anyOf);
3302 if (num != -1)
3303 {
3304 return num + startIndex;
3305 }
3306 return num;
3307 }
3308 if (anyOf.Length > 5)
3309 {
3311 }
3312 return -1;
3313 }
3314
3315 private unsafe int IndexOfCharArray(char[] anyOf, int startIndex, int count)
3316 {
3318 uint* charMap = (uint*)(&probabilisticMap);
3320 fixed (char* ptr = &_firstChar)
3321 {
3322 char* ptr2 = ptr + startIndex;
3323 while (count > 0)
3324 {
3325 int num = *ptr2;
3326 if (IsCharBitSet(charMap, (byte)num) && IsCharBitSet(charMap, (byte)(num >> 8)) && ArrayContains((char)num, anyOf))
3327 {
3328 return (int)(ptr2 - ptr);
3329 }
3330 count--;
3331 ptr2++;
3332 }
3333 return -1;
3334 }
3335 }
3336
3338 {
3339 bool flag = false;
3340 for (int i = 0; i < anyOf.Length; i++)
3341 {
3342 int num = anyOf[i];
3343 SetCharBit(charMap, (byte)num);
3344 num >>= 8;
3345 if (num == 0)
3346 {
3347 flag = true;
3348 }
3349 else
3350 {
3351 SetCharBit(charMap, (byte)num);
3352 }
3353 }
3354 if (flag)
3355 {
3356 *charMap |= 1u;
3357 }
3358 }
3359
3360 private static bool ArrayContains(char searchChar, char[] anyOf)
3361 {
3362 for (int i = 0; i < anyOf.Length; i++)
3363 {
3364 if (anyOf[i] == searchChar)
3365 {
3366 return true;
3367 }
3368 }
3369 return false;
3370 }
3371
3372 private unsafe static bool IsCharBitSet(uint* charMap, byte value)
3373 {
3374 return (charMap[(uint)(value & 7)] & (uint)(1 << (value >> 3))) != 0;
3375 }
3376
3377 private unsafe static void SetCharBit(uint* charMap, byte value)
3378 {
3379 charMap[(uint)(value & 7)] |= (uint)(1 << (value >> 3));
3380 }
3381
3382 public int IndexOf(string value)
3383 {
3384 return IndexOf(value, StringComparison.CurrentCulture);
3385 }
3386
3387 public int IndexOf(string value, int startIndex)
3388 {
3389 return IndexOf(value, startIndex, StringComparison.CurrentCulture);
3390 }
3391
3392 public int IndexOf(string value, int startIndex, int count)
3393 {
3394 return IndexOf(value, startIndex, count, StringComparison.CurrentCulture);
3395 }
3396
3398 {
3399 return IndexOf(value, 0, Length, comparisonType);
3400 }
3401
3406
3408 {
3409 switch (comparisonType)
3410 {
3411 case StringComparison.CurrentCulture:
3412 case StringComparison.CurrentCultureIgnoreCase:
3414 case StringComparison.InvariantCulture:
3415 case StringComparison.InvariantCultureIgnoreCase:
3417 case StringComparison.Ordinal:
3418 case StringComparison.OrdinalIgnoreCase:
3419 return Ordinal.IndexOf(this, value, startIndex, count, comparisonType == StringComparison.OrdinalIgnoreCase);
3420 default:
3421 throw ((object)value == null) ? new ArgumentNullException("value") : new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
3422 }
3423 }
3424
3425 public int LastIndexOf(char value)
3426 {
3428 }
3429
3430 public int LastIndexOf(char value, int startIndex)
3431 {
3432 return LastIndexOf(value, startIndex, startIndex + 1);
3433 }
3434
3435 public int LastIndexOf(char value, int startIndex, int count)
3436 {
3437 if (Length == 0)
3438 {
3439 return -1;
3440 }
3441 if ((uint)startIndex >= (uint)Length)
3442 {
3444 }
3445 if ((uint)count > (uint)(startIndex + 1))
3446 {
3448 }
3449 int num = startIndex + 1 - count;
3451 if (num2 != -1)
3452 {
3453 return num2 + num;
3454 }
3455 return num2;
3456 }
3457
3458 public int LastIndexOfAny(char[] anyOf)
3459 {
3460 return LastIndexOfAny(anyOf, Length - 1, Length);
3461 }
3462
3463 public int LastIndexOfAny(char[] anyOf, int startIndex)
3464 {
3466 }
3467
3468 public int LastIndexOfAny(char[] anyOf, int startIndex, int count)
3469 {
3470 if (anyOf == null)
3471 {
3472 throw new ArgumentNullException("anyOf");
3473 }
3474 if (Length == 0)
3475 {
3476 return -1;
3477 }
3478 if ((uint)startIndex >= (uint)Length)
3479 {
3481 }
3483 {
3485 }
3486 if (anyOf.Length > 1)
3487 {
3489 }
3490 if (anyOf.Length == 1)
3491 {
3492 return LastIndexOf(anyOf[0], startIndex, count);
3493 }
3494 return -1;
3495 }
3496
3497 private unsafe int LastIndexOfCharArray(char[] anyOf, int startIndex, int count)
3498 {
3500 uint* charMap = (uint*)(&probabilisticMap);
3502 fixed (char* ptr = &_firstChar)
3503 {
3504 char* ptr2 = ptr + startIndex;
3505 while (count > 0)
3506 {
3507 int num = *ptr2;
3508 if (IsCharBitSet(charMap, (byte)num) && IsCharBitSet(charMap, (byte)(num >> 8)) && ArrayContains((char)num, anyOf))
3509 {
3510 return (int)(ptr2 - ptr);
3511 }
3512 count--;
3513 ptr2--;
3514 }
3515 return -1;
3516 }
3517 }
3518
3519 public int LastIndexOf(string value)
3520 {
3521 return LastIndexOf(value, Length - 1, Length, StringComparison.CurrentCulture);
3522 }
3523
3524 public int LastIndexOf(string value, int startIndex)
3525 {
3526 return LastIndexOf(value, startIndex, startIndex + 1, StringComparison.CurrentCulture);
3527 }
3528
3529 public int LastIndexOf(string value, int startIndex, int count)
3530 {
3531 return LastIndexOf(value, startIndex, count, StringComparison.CurrentCulture);
3532 }
3533
3535 {
3537 }
3538
3543
3545 {
3546 switch (comparisonType)
3547 {
3548 case StringComparison.CurrentCulture:
3549 case StringComparison.CurrentCultureIgnoreCase:
3551 case StringComparison.InvariantCulture:
3552 case StringComparison.InvariantCultureIgnoreCase:
3554 case StringComparison.Ordinal:
3555 case StringComparison.OrdinalIgnoreCase:
3557 default:
3558 throw ((object)value == null) ? new ArgumentNullException("value") : new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
3559 }
3560 }
3561}
static unsafe int MultiByteToWideChar(uint CodePage, uint dwFlags, byte *lpMultiByteStr, int cbMultiByte, char *lpWideCharStr, int cchWideChar)
static void Memmove(ref byte dest, ref byte src, nuint len)
Definition Buffer.cs:215
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static decimal ToDecimal(object? value)
Definition Convert.cs:2101
static long ToInt64(object? value)
Definition Convert.cs:1623
static float ToSingle(object? value)
Definition Convert.cs:1881
static int ToInt32(object? value)
Definition Convert.cs:1320
static DateTime ToDateTime(DateTime value)
Definition Convert.cs:2211
static short ToInt16(object? value)
Definition Convert.cs:1038
static byte ToByte(object? value)
Definition Convert.cs:900
static uint ToUInt32(object? value)
Definition Convert.cs:1470
static ulong ToUInt64(object? value)
Definition Convert.cs:1738
static char ToChar(object? value)
Definition Convert.cs:618
static ushort ToUInt16(object? value)
Definition Convert.cs:1177
static sbyte ToSByte(object? value)
Definition Convert.cs:745
static double ToDouble(object? value)
Definition Convert.cs:1991
static bool ToBoolean([NotNullWhen(true)] object? value)
Definition Convert.cs:508
static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
Definition Convert.cs:269
static readonly CompareInfo Invariant
static CultureInfo CurrentCulture
static string Normalize(string strInput, NormalizationForm normalizationForm)
static bool IsNormalized(string strInput, NormalizationForm normalizationForm)
static int IndexOf(string source, string value, int startIndex, int count, bool ignoreCase)
Definition Ordinal.cs:122
static bool EqualsIgnoreCase(ref char charA, ref char charB, int length)
Definition Ordinal.cs:57
static int ToUpperOrdinal(ReadOnlySpan< char > source, Span< char > destination)
Definition Ordinal.cs:193
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
Definition Ordinal.cs:8
static readonly TextInfo Invariant
Definition TextInfo.cs:42
static ulong DefaultSeed
Definition Marvin.cs:13
static int ComputeHash32OrdinalIgnoreCase(ref char data, int count, uint p0, uint p1)
Definition Marvin.cs:106
static int ComputeHash32(ReadOnlySpan< byte > data, ulong seed)
Definition Marvin.cs:17
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static uint RotateLeft(uint value, int offset)
static Vector< float > ConditionalSelect(Vector< int > condition, Vector< float > left, Vector< float > right)
Definition Vector.cs:24
static bool IsHardwareAccelerated
Definition Vector.cs:14
static Vector< int > Equals(Vector< float > left, Vector< float > right)
Definition Vector.cs:52
static unsafe ref byte GetArrayDataReference(Array array)
static Vector128< byte > Create(byte value)
Definition Vector128.cs:138
static uint ConvertToUInt32(Vector128< uint > value)
Definition Sse2.cs:512
static Vector128< sbyte > CompareEqual(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse2.cs:232
static Vector128< byte > Or(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:837
static Vector128< short > ShiftRightLogical(Vector128< short > value, Vector128< short > count)
Definition Sse2.cs:1057
static bool TestZ(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse41.cs:692
static Vector128< sbyte > Shuffle(Vector128< sbyte > value, Vector128< sbyte > mask)
Definition Ssse3.cs:112
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string ArgumentOutOfRange_NegativeCount
Definition SR.cs:1080
static string ArgumentOutOfRange_IndexCount
Definition SR.cs:80
static string ArgumentOutOfRange_Count
Definition SR.cs:986
static string ArgumentOutOfRange_NegativeLength
Definition SR.cs:1082
static string Arg_MustBeString
Definition SR.cs:298
static string Argument_StringZeroLength
Definition SR.cs:882
static string ArgumentOutOfRange_PartialWCHAR
Definition SR.cs:1090
static string ArgumentOutOfRange_IndexCountBuffer
Definition SR.cs:78
static string ArgumentOutOfRange_StartIndex
Definition SR.cs:1106
static string ArgumentOutOfRange_StartIndexLargerThanLength
Definition SR.cs:1108
static string Arg_MustBeNullTerminatedString
Definition SR.cs:2080
static string Arg_InvalidANSIString
Definition SR.cs:194
static string ArgumentOutOfRange_IndexLength
Definition SR.cs:1034
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
static string NotSupported_StringComparison
Definition SR.cs:1712
Definition SR.cs:7
static bool Contains(ref byte searchSpace, byte value, int length)
static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint length)
static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static StringComparer FromComparison(StringComparison comparisonType)
string[] Split(string[]? separator, int count, StringSplitOptions options)
Definition String.cs:2670
ref char GetRawStringData()
Definition String.cs:1351
static bool EqualsHelper(string strA, string strB)
Definition String.cs:110
string ReplaceHelper(int oldValueLength, string newValue, ReadOnlySpan< int > indices)
Definition String.cs:2494
CharEnumerator GetEnumerator()
Definition String.cs:1396
static string Concat(string? str0, string? str1, string? str2)
Definition String.cs:1735
bool EndsWith(string value)
Definition String.cs:448
static bool ArrayContains(char searchChar, char[] anyOf)
Definition String.cs:3360
void CopyTo(Span< char > destination)
Definition String.cs:1264
string Ctor(ReadOnlySpan< char > value)
Definition String.cs:1159
int IndexOfAny(char[] anyOf, int startIndex, int count)
Definition String.cs:3285
int IndexOf(string value, int startIndex)
Definition String.cs:3387
static string Format(string format, object? arg0)
Definition String.cs:1897
string Insert(int startIndex, string value)
Definition String.cs:1958
string[] Split(char separator, int count, StringSplitOptions options=StringSplitOptions.None)
Definition String.cs:2583
static string JoinCore< T >(ReadOnlySpan< char > separator, IEnumerable< T > values)
Definition String.cs:2121
string TrimStart()
Definition String.cs:3088
static int Compare(string? strA, string? strB, CultureInfo? culture, CompareOptions options)
Definition String.cs:261
int LastIndexOf(char value)
Definition String.cs:3425
static string CreateFromChar(char c1, char c2)
Definition String.cs:1378
String(char c, int count)
string[] SplitWithPostProcessing(ReadOnlySpan< int > sepList, ReadOnlySpan< int > lengthList, int defaultLength, int count, StringSplitOptions options)
Definition String.cs:2785
static string Concat(string? str0, string? str1)
Definition String.cs:1714
static string Concat(ReadOnlySpan< char > str0, ReadOnlySpan< char > str1, ReadOnlySpan< char > str2)
Definition String.cs:1798
bool EndsWith(char value)
Definition String.cs:511
string Replace(string oldValue, string? newValue, StringComparison comparisonType)
Definition String.cs:2329
static string Concat(params object?[] args)
Definition String.cs:1584
string ToLowerInvariant()
Definition String.cs:3045
unsafe String(sbyte *value, int startIndex, int length, Encoding enc)
bool TryGetSpan(int startIndex, int count, out ReadOnlySpan< char > slice)
Definition String.cs:1210
static string ReplaceCore(ReadOnlySpan< char > searchSpace, ReadOnlySpan< char > oldValue, ReadOnlySpan< char > newValue, CompareInfo compareInfo, CompareOptions options)
Definition String.cs:2361
bool TryCopyTo(Span< char > destination)
Definition String.cs:1277
static string Join(char separator, params string?[] value)
Definition String.cs:1986
string[] Split(char[]? separator, int count)
Definition String.cs:2593
static string Create(IFormatProvider? provider, Span< char > initialBuffer, [InterpolatedStringHandlerArgument(new string[] { "provider", "initialBuffer" })] ref DefaultInterpolatedStringHandler handler)
Definition String.cs:1194
static unsafe void SetCharBit(uint *charMap, byte value)
Definition String.cs:3377
static string JoinCore(ReadOnlySpan< char > separator, string[] value, int startIndex, int count)
Definition String.cs:2014
string Intern()
static int GetHashCode(ReadOnlySpan< char > value, StringComparison comparisonType)
Definition String.cs:678
string Ctor(char[] value)
Definition String.cs:904
unsafe string TrimEnd(params char[]? trimChars)
Definition String.cs:3120
void MakeSeparatorList(string[] separators, ref ValueListBuilder< int > sepListBuilder, ref ValueListBuilder< int > lengthListBuilder)
Definition String.cs:2963
static int Compare(string? strA, string? strB)
Definition String.cs:212
static string Join(char separator, string?[] value, int startIndex, int count)
Definition String.cs:2004
static int GetHashCodeOrdinalIgnoreCase(ReadOnlySpan< char > value)
Definition String.cs:699
static void CheckStringComparison(StringComparison comparisonType)
Definition String.cs:882
int IndexOf(string value, StringComparison comparisonType)
Definition String.cs:3397
static string Create< TState >(int length, TState state, SpanAction< char, TState > action)
Definition String.cs:1170
static string Intern(string str)
Definition String.cs:75
static int Compare(string? strA, int indexA, string? strB, int indexB, int length)
Definition String.cs:273
static int Compare(string? strA, string? strB, StringComparison comparisonType)
Definition String.cs:223
string PadRight(int totalWidth)
Definition String.cs:2262
int IndexOf(string value, int startIndex, int count)
Definition String.cs:3392
static unsafe void InitializeProbabilisticMap(uint *charMap, ReadOnlySpan< char > anyOf)
Definition String.cs:3337
string Substring(int startIndex, int length)
Definition String.cs:2997
string Normalize(NormalizationForm normalizationForm)
Definition String.cs:1543
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
Definition String.cs:1238
TypeCode GetTypeCode()
Definition String.cs:1444
string[] SplitInternal(string separator, int count, StringSplitOptions options)
Definition String.cs:2734
string ReplaceLineEndings()
Definition String.cs:2522
static unsafe int CompareOrdinalHelper(string strA, string strB)
Definition String.cs:143
static bool Equals(string? a, string? b, StringComparison comparisonType)
Definition String.cs:605
int GetHashCode(StringComparison comparisonType)
Definition String.cs:659
int CompareTo(string? strB)
Definition String.cs:443
static string FormatHelper(IFormatProvider provider, string format, ParamsArray args)
Definition String.cs:1945
static bool operator==(string? a, string? b)
Definition String.cs:642
string Replace(string oldValue, string? newValue)
Definition String.cs:2436
static int Compare(string? strA, int indexA, string? strB, int indexB, int length, bool ignoreCase, CultureInfo? culture)
Definition String.cs:294
int IndexOf(char value, StringComparison comparisonType)
Definition String.cs:3238
int LastIndexOf(string value, int startIndex)
Definition String.cs:3524
string[] Split(string? separator, StringSplitOptions options=StringSplitOptions.None)
Definition String.cs:2655
static string Join(string? separator, params string?[] value)
Definition String.cs:1995
string InternalSubString(int startIndex, int length)
Definition String.cs:3026
int IndexOf(string value, int startIndex, int count, StringComparison comparisonType)
Definition String.cs:3407
static string Concat(IEnumerable< string?> values)
Definition String.cs:1687
bool StartsWith(string value, bool ignoreCase, CultureInfo? culture)
Definition String.cs:859
string Substring(int startIndex)
Definition String.cs:2992
unsafe string TrimEnd(char trimChar)
Definition String.cs:3115
override int GetHashCode()
Definition String.cs:653
String(char[] value, int startIndex, int length)
string[] Split(char[]? separator, StringSplitOptions options)
Definition String.cs:2598
int LastIndexOf(string value, StringComparison comparisonType)
Definition String.cs:3534
static string Concat(params string?[] values)
Definition String.cs:1834
int IndexOf(char value, int startIndex, int count)
Definition String.cs:3257
static string Join(string? separator, IEnumerable< string?> values)
Definition String.cs:2035
string[] Split(char separator, StringSplitOptions options=StringSplitOptions.None)
Definition String.cs:2578
string ToUpper(CultureInfo? culture)
Definition String.cs:3055
string[] Split(string? separator, int count, StringSplitOptions options=StringSplitOptions.None)
Definition String.cs:2660
bool IsNormalized(NormalizationForm normalizationForm)
Definition String.cs:1529
string ReplaceCore(string oldValue, string newValue, CompareInfo ci, CompareOptions options)
Definition String.cs:2348
static bool IsNullOrWhiteSpace([NotNullWhen(false)] string? value)
Definition String.cs:1328
static string Format(string format, object? arg0, object? arg1, object? arg2)
Definition String.cs:1907
static int CompareOrdinal(ReadOnlySpan< char > strA, ReadOnlySpan< char > strB)
Definition String.cs:388
static int Compare(string? strA, string? strB, bool ignoreCase)
Definition String.cs:217
static unsafe bool IsCharBitSet(uint *charMap, byte value)
Definition String.cs:3372
string PadLeft(int totalWidth, char paddingChar)
Definition String.cs:2244
static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1)
Definition String.cs:1926
string TrimEnd()
Definition String.cs:3110
static CompareOptions GetCaseCompareOfComparisonCulture(StringComparison comparisonType)
Definition String.cs:890
static int Compare(string? strA, int indexA, string? strB, int indexB, int length, bool ignoreCase)
Definition String.cs:278
static int Compare(string? strA, int indexA, string? strB, int indexB, int length, CultureInfo? culture, CompareOptions options)
Definition String.cs:300
override string ToString()
Definition String.cs:1386
override bool Equals([NotNullWhen(true)] object? obj)
Definition String.cs:521
unsafe int GetNonRandomizedHashCodeOrdinalIgnoreCase()
Definition String.cs:728
static string Concat(string? str0, string? str1, string? str2, string? str3)
Definition String.cs:1757
unsafe string TrimStart(params char[]? trimChars)
Definition String.cs:3098
static ? string IsInterned(string str)
Definition String.cs:84
readonly int _stringLength
Definition String.cs:32
int IndexOfAny(char[] anyOf)
Definition String.cs:3275
string Ctor(char[] value, int startIndex, int length)
Definition String.cs:920
bool Equals([NotNullWhen(true)] string? value)
Definition String.cs:538
unsafe string Trim(params char[]? trimChars)
Definition String.cs:3076
string TrimWhiteSpaceHelper(TrimType trimType)
Definition String.cs:3132
static readonly string Empty
Definition String.cs:29
int LastIndexOf(string value, int startIndex, int count)
Definition String.cs:3529
static string Create(IFormatProvider? provider, [InterpolatedStringHandlerArgument("provider")] ref DefaultInterpolatedStringHandler handler)
Definition String.cs:1189
static int Compare(string? strA, string? strB, bool ignoreCase, CultureInfo? culture)
Definition String.cs:267
bool Contains(char value)
Definition String.cs:3218
string[] SplitWithoutPostProcessing(ReadOnlySpan< int > sepList, ReadOnlySpan< int > lengthList, int defaultLength, int count)
Definition String.cs:2758
ref readonly char GetPinnableReference()
Definition String.cs:1346
bool Contains(string value, StringComparison comparisonType)
Definition String.cs:3213
bool Equals([NotNullWhen(true)] string? value, StringComparison comparisonType)
Definition String.cs:555
unsafe String(char *value)
string Replace(char oldChar, char newChar)
Definition String.cs:2389
string ToUpper()
Definition String.cs:3050
static string Concat(object? arg0, object? arg1, object? arg2)
Definition String.cs:1579
char _firstChar
Definition String.cs:35
static string Join(string? separator, params object?[] values)
Definition String.cs:2076
string[] Split(char[]? separator, int count, StringSplitOptions options)
Definition String.cs:2603
static bool EqualsOrdinalIgnoreCase(string strA, string strB)
Definition String.cs:121
static string JoinCore(ReadOnlySpan< char > separator, object[] values)
Definition String.cs:2081
static string Join(char separator, params object?[] values)
Definition String.cs:2071
static bool Equals(string? a, string? b)
Definition String.cs:592
string ToLower(CultureInfo? culture)
Definition String.cs:3039
int IndexOf(char value)
Definition String.cs:3228
unsafe string Ctor(char c, int count)
Definition String.cs:1112
static unsafe void InternalCopy(string src, IntPtr dest, int len)
Definition String.cs:93
static unsafe string CreateStringFromEncoding(byte *bytes, int byteLength, Encoding encoding)
Definition String.cs:1356
bool StartsWith(char value)
Definition String.cs:873
static string Concat< T >(IEnumerable< T > values)
Definition String.cs:1631
unsafe string TrimStart(char trimChar)
Definition String.cs:3093
static void ThrowMustBeNullTerminatedString()
Definition String.cs:1439
int IndexOf(char value, int startIndex)
Definition String.cs:3233
unsafe String(sbyte *value)
string ToUpperInvariant()
Definition String.cs:3061
unsafe string Ctor(sbyte *value)
Definition String.cs:1009
static CompareOptions GetCompareOptionsFromOrdinalStringComparison(StringComparison comparisonType)
Definition String.cs:895
unsafe string Ctor(char *ptr, int startIndex, int length)
Definition String.cs:975
static string Format(IFormatProvider? provider, string format, params object?[] args)
Definition String.cs:1936
static string CreateFromChar(char c)
Definition String.cs:1371
string IsInterned()
static int CompareOrdinal(string? strA, string? strB)
Definition String.cs:366
static string Format(IFormatProvider? provider, string format, object? arg0)
Definition String.cs:1921
unsafe String(char *value, int startIndex, int length)
static void CheckStringSplitOptions(StringSplitOptions options)
Definition String.cs:2984
static unsafe int strlen(byte *ptr)
Definition String.cs:1428
int LastIndexOf(char value, int startIndex)
Definition String.cs:3430
unsafe string Ctor(char *ptr)
Definition String.cs:953
static string Join< T >(char separator, IEnumerable< T > values)
Definition String.cs:2111
bool StartsWith(string value, StringComparison comparisonType)
Definition String.cs:814
string Normalize()
Definition String.cs:1538
unsafe int GetNonRandomizedHashCode()
Definition String.cs:705
static string Concat(ReadOnlySpan< char > str0, ReadOnlySpan< char > str1, ReadOnlySpan< char > str2, ReadOnlySpan< char > str3)
Definition String.cs:1815
int IndexOf(string value, int startIndex, StringComparison comparisonType)
Definition String.cs:3402
static void FillStringChecked(string dest, int destPos, string src)
Definition String.cs:1560
String(ReadOnlySpan< char > value)
void MakeSeparatorListVectorized(ref ValueListBuilder< int > sepListBuilder, char c, char c2, char c3)
Definition String.cs:2887
static int IndexOfNewlineChar(ReadOnlySpan< char > text, out int stride)
Definition String.cs:2559
unsafe string Ctor(sbyte *value, int startIndex, int length)
Definition String.cs:1024
unsafe string TrimHelper(char *trimChars, int trimCharsLength, TrimType trimType)
Definition String.cs:3153
static unsafe int wcslen(char *ptr)
Definition String.cs:1417
String(char[]? value)
static string Copy(string str)
Definition String.cs:1226
string ToString(IFormatProvider? provider)
Definition String.cs:1391
int LastIndexOf(string value)
Definition String.cs:3519
static int Compare(string? strA, int indexA, string? strB, int indexB, int length, StringComparison comparisonType)
Definition String.cs:316
static string FastAllocateString(int length)
unsafe string Ctor(sbyte *value, int startIndex, int length, Encoding enc)
Definition String.cs:1078
unsafe int LastIndexOfCharArray(char[] anyOf, int startIndex, int count)
Definition String.cs:3497
string Replace(string oldValue, string? newValue, bool ignoreCase, CultureInfo? culture)
Definition String.cs:2324
string Remove(int startIndex, int count)
Definition String.cs:2285
unsafe int GetBytesFromEncoding(byte *pbNativeBuffer, int cbNativeBuffer, Encoding encoding)
Definition String.cs:101
bool EndsWith(string value, bool ignoreCase, CultureInfo? culture)
Definition String.cs:497
static string Concat(ReadOnlySpan< char > str0, ReadOnlySpan< char > str1)
Definition String.cs:1784
static string Format(string format, object? arg0, object? arg1)
Definition String.cs:1902
int LastIndexOf(char value, int startIndex, int count)
Definition String.cs:3435
static bool IsNullOrEmpty([NotNullWhen(false)] string? value)
Definition String.cs:1319
static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2)
Definition String.cs:1931
bool IsNormalized()
Definition String.cs:1524
bool StartsWith(string value)
Definition String.cs:805
static int CompareOrdinalHelper(string strA, int indexA, int countA, string strB, int indexB, int countB)
Definition String.cs:116
bool EndsWith(string value, StringComparison comparisonType)
Definition String.cs:453
static bool EqualsOrdinalIgnoreCaseNoLengthCheck(string strA, string strB)
Definition String.cs:138
unsafe void MakeSeparatorList(ReadOnlySpan< char > separators, ref ValueListBuilder< int > sepListBuilder)
Definition String.cs:2841
int LastIndexOfAny(char[] anyOf, int startIndex)
Definition String.cs:3463
char[] ToCharArray()
Definition String.cs:1288
int LastIndexOfAny(char[] anyOf, int startIndex, int count)
Definition String.cs:3468
string Trim()
Definition String.cs:3066
string Remove(int startIndex)
Definition String.cs:2315
unsafe string Trim(char trimChar)
Definition String.cs:3071
static int GetHashCode(ReadOnlySpan< char > value)
Definition String.cs:672
static string Concat(object? arg0)
Definition String.cs:1569
void MakeSeparatorList(string separator, ref ValueListBuilder< int > sepListBuilder)
Definition String.cs:2950
bool Contains(char value, StringComparison comparisonType)
Definition String.cs:3223
static int CompareOrdinal(string? strA, int indexA, string? strB, int indexB, int length)
Definition String.cs:393
static string Join(string? separator, string?[] value, int startIndex, int count)
Definition String.cs:2009
int IndexOfAny(char[] anyOf, int startIndex)
Definition String.cs:3280
string[] SplitInternal(ReadOnlySpan< char > separators, int count, StringSplitOptions options)
Definition String.cs:2608
string CreateTrimmedString(int start, int end)
Definition String.cs:3190
string[] SplitInternal(string separator, string[] separators, int count, StringSplitOptions options)
Definition String.cs:2675
int LastIndexOfAny(char[] anyOf)
Definition String.cs:3458
string[] Split(params char[]? separator)
Definition String.cs:2588
string PadRight(int totalWidth, char paddingChar)
Definition String.cs:2267
string[] Split(string[]? separator, StringSplitOptions options)
Definition String.cs:2665
string PadLeft(int totalWidth)
Definition String.cs:2239
static string Concat(object? arg0, object? arg1)
Definition String.cs:1574
int IndexOf(string value)
Definition String.cs:3382
string ToLower()
Definition String.cs:3034
int CompareTo(object? value)
Definition String.cs:430
int LastIndexOf(string value, int startIndex, StringComparison comparisonType)
Definition String.cs:3539
bool TryGetTrailByte(out byte data)
void SetTrailByte(byte data)
StringRuneEnumerator EnumerateRunes()
Definition String.cs:1411
char[] ToCharArray(int startIndex, int length)
Definition String.cs:1299
unsafe bool IsAscii()
Definition String.cs:1552
static string JoinCore(ReadOnlySpan< char > separator, ReadOnlySpan< string > values)
Definition String.cs:2164
unsafe int IndexOfCharArray(char[] anyOf, int startIndex, int count)
Definition String.cs:3315
int GetHashCodeOrdinalIgnoreCase()
Definition String.cs:665
static bool operator!=(string? a, string? b)
Definition String.cs:647
unsafe String(sbyte *value, int startIndex, int length)
static unsafe string CreateStringForSByteConstructor(byte *pb, int numBytes)
Definition String.cs:1050
static string Format(string format, params object?[] args)
Definition String.cs:1912
bool Contains(string value)
Definition String.cs:3204
object Clone()
Definition String.cs:1221
int LastIndexOf(string value, int startIndex, int count, StringComparison comparisonType)
Definition String.cs:3544
string ReplaceLineEndings(string replacementText)
Definition String.cs:2527
static unsafe nuint GetIndexOfFirstNonAsciiChar(char *pBuffer, nuint bufferLength)
virtual int GetCharCount(byte[] bytes)
Definition Encoding.cs:887
virtual byte[] GetBytes(char[] chars)
Definition Encoding.cs:781
virtual char[] GetChars(byte[] bytes)
Definition Encoding.cs:921
static bool AllCharsInUInt32AreAscii(uint value)
static void ThrowIndexOutOfRangeException()
static void ThrowOutOfMemoryException()
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowArgumentException_DestinationTooShort()
new IEnumerator< T > GetEnumerator()
short ToInt16(IFormatProvider? provider)
char ToChar(IFormatProvider? provider)
byte ToByte(IFormatProvider? provider)
decimal ToDecimal(IFormatProvider? provider)
object ToType(Type conversionType, IFormatProvider? provider)
uint ToUInt32(IFormatProvider? provider)
DateTime ToDateTime(IFormatProvider? provider)
int ToInt32(IFormatProvider? provider)
long ToInt64(IFormatProvider? provider)
ushort ToUInt16(IFormatProvider? provider)
double ToDouble(IFormatProvider? provider)
float ToSingle(IFormatProvider? provider)
sbyte ToSByte(IFormatProvider? provider)
ulong ToUInt64(IFormatProvider? provider)
bool ToBoolean(IFormatProvider? provider)
TypeCode
Definition TypeCode.cs:4