Last active
November 20, 2017 16:53
-
-
Save kuhlenh/4d85c9a58f9f15e3f8c19bc35d34051e to your computer and use it in GitHub Desktop.
Example from Span<T> in CoreCLR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReadOnlySpan<char> valueSpan = value.AsReadOnlySpan(); | |
if (!Int32.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) || | |
!Int32.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) || | |
!Int32.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day)) | |
{ | |
// Couldn't convert integer, fail | |
return null; | |
} | |
// see entire example : https://github.com/dotnet/coreclr/blob/a16fdf04c50fd7b14b939835a040bd21084f1dc4/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs#L162-L165 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment