File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
src/ZirconNet.Core/Extensions Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Diagnostics . CodeAnalysis ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+
8+ namespace ZirconNet . Core . Extensions ;
9+
10+ #if NET7_0_OR_GREATER
11+ public static class ParsableExtensions
12+ {
13+ public static T Parse < T > ( this string input , IFormatProvider ? formatProvider = null )
14+ where T : IParsable < T >
15+ {
16+ return T . Parse ( input , formatProvider ) ;
17+ }
18+
19+
20+ public static T Parse < T > ( this ReadOnlySpan < char > input , IFormatProvider ? formatProvider = null )
21+ where T : ISpanParsable < T >
22+ {
23+ return T . Parse ( input , formatProvider ) ;
24+ }
25+
26+ public static bool TryParse < T > ( this string input , IFormatProvider ? formatProvider , [ MaybeNullWhen ( false ) ] out T result )
27+ where T : IParsable < T >
28+ {
29+ return T . TryParse ( input , formatProvider , out result ) ;
30+ }
31+
32+
33+ public static bool TryParse < T > ( this ReadOnlySpan < char > input , IFormatProvider ? formatProvider , [ MaybeNullWhen ( false ) ] out T result )
34+ where T : ISpanParsable < T >
35+ {
36+ return T . TryParse ( input , formatProvider , out result ) ;
37+ }
38+ }
39+ #endif
You can’t perform that action at this time.
0 commit comments