Question: Is there built in ToUpper() functionality for System.Guid and other value types ? #97795
Replies: 2 comments
-
It would be nice for format specifiers to work like this (and I think for some types they do work like that):
but it'd be a breaking change to introduce this now in void ToUpper(Guid guid, Span<char> dest, ReadOnlySpan<char> format)
{
guid.TryFormat(dest, out var charsWritten, format);
Ascii.ToUpperInPlace(dest.Slice(0, charsWritten), out _);
} |
Beta Was this translation helpful? Give feedback.
-
@EgorBo Thank you for the proposal. I've updated the extension method to reflect it.
BenchmarkDotNet v0.13.10, Windows 11 (10.0.22631.3085/23H2/2023Update/SunValley3)
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Today I was a bit disappointed that there is no built in way to convert guid in upper case. Or maybe I am wrong and it exists...
And wondering if this can be done in a less allocative way - here it is what I produced as extension.
and usage :
Produces:
Hello, World: {0XCAC5A108,0X1B0F,0X49EC,{0XA5,0XCB,0X16,0X90,0X33,0X32,0XF5,0X4B}}
Hello, World: 1EA856EC4737462890D85AA9398FC7E1
Hello, World: {AC5A2F0B-8C7A-4135-8174-86F371E46D56}
Hello, World: (71309472-FA76-47F2-A22F-B1F8C7503A9A)
Hello, World: 3E41F3BA-D001-4F11-AEA2-9A1F3D56674D
Do you think if there are more effective way of doing this?
Also is this a valuable pattern to be used for other types like Date/DateTime..... ?
Beta Was this translation helpful? Give feedback.
All reactions