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

◆ ToString() [3/3]

string System.Guid.ToString ( string? format,
IFormatProvider? provider )
inline

Implements System.IFormattable.

Definition at line 884 of file Guid.cs.

885 {
886 if (string.IsNullOrEmpty(format))
887 {
888 format = "D";
889 }
890 if (format.Length != 1)
891 {
892 throw new FormatException(SR.Format_InvalidGuidFormatSpecification);
893 }
894 int length;
895 switch (format[0])
896 {
897 case 'D':
898 case 'd':
899 length = 36;
900 break;
901 case 'N':
902 case 'n':
903 length = 32;
904 break;
905 case 'B':
906 case 'P':
907 case 'b':
908 case 'p':
909 length = 38;
910 break;
911 case 'X':
912 case 'x':
913 length = 68;
914 break;
915 default:
916 throw new FormatException(SR.Format_InvalidGuidFormatSpecification);
917 }
918 string text = string.FastAllocateString(length);
919 int charsWritten;
920 bool flag = TryFormat(new Span<char>(ref text.GetRawStringData(), text.Length), out charsWritten, format);
921 return text;
922 }
unsafe bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >))
Definition Guid.cs:924

References System.format, System.SR.Format_InvalidGuidFormatSpecification, System.length, System.text, and System.Guid.TryFormat().