33
44namespace Polyfills ;
55
6+ using System ;
67using System . Collections . Generic ;
78using System . Diagnostics ;
89using System . Diagnostics . CodeAnalysis ;
@@ -18,7 +19,7 @@ static partial class StringPolyfill
1819 /// Concatenates an array of strings, using the specified separator between each member.
1920 /// </summary>
2021 //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string())
21- public static string Join ( char separator , string [ ] values ) =>
22+ public static string Join ( char separator , params string [ ] values ) =>
2223#if NETSTANDARD2_0 || NETFRAMEWORK
2324 string . Join ( new ( [ separator ] ) , values ) ;
2425#else
@@ -29,13 +30,59 @@ public static string Join(char separator, string[] values) =>
2930 /// Concatenates the string representations of an array of objects, using the specified separator between each member.
3031 /// </summary>
3132 //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())
32- public static string Join ( char separator , object [ ] values ) =>
33+ public static string Join ( char separator , params object [ ] values ) =>
3334#if NETSTANDARD2_0 || NETFRAMEWORK
3435 string . Join ( new ( [ separator ] ) , values ) ;
3536#else
3637 string . Join ( separator , values ) ;
3738#endif
3839
40+ #if FeatureMemory
41+ /// <summary>
42+ /// Concatenates the string representations of a span of objects, using the specified separator between each member.
43+ /// </summary>
44+ //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-readonlyspan((system-object)))
45+ public static string Join ( char separator , scoped ReadOnlySpan < object ? > values ) =>
46+ #if NET9_0_OR_GREATER
47+ string . Join ( separator , values ) ;
48+ #else
49+ Join ( separator , values . ToArray ( ) ) ;
50+ #endif
51+
52+ /// <summary>
53+ /// Concatenates a span of strings, using the specified separator between each member.
54+ /// </summary>
55+ //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-readonlyspan((system-string)))
56+ public static string Join ( char separator , scoped ReadOnlySpan < string ? > values ) =>
57+ #if NET9_0_OR_GREATER
58+ string . Join ( separator , values ) ;
59+ #else
60+ Join ( separator , values . ToArray ( ) ) ;
61+ #endif
62+
63+ /// <summary>
64+ /// Concatenates the string representations of a span of objects, using the specified separator between each member.
65+ /// </summary>
66+ //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-string-system-readonlyspan((system-object)))
67+ public static string Join ( string separator , scoped ReadOnlySpan < object ? > values ) =>
68+ #if NET9_0_OR_GREATER
69+ string . Join ( separator , values ) ;
70+ #else
71+ string . Join ( separator , values . ToArray ( ) ) ;
72+ #endif
73+
74+ /// <summary>
75+ /// Concatenates a span of strings, using the specified separator between each member.
76+ /// </summary>
77+ //Link: https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-string-system-readonlyspan((system-string)))
78+ public static string Join ( string separator , scoped ReadOnlySpan < string ? > values ) =>
79+ #if NET9_0_OR_GREATER
80+ string . Join ( separator , values ) ;
81+ #else
82+ string . Join ( separator , values . ToArray ( ) ) ;
83+ #endif
84+ #endif
85+
3986 /// <summary>
4087 /// Concatenates the specified elements of a string array, using the specified separator between each element.
4188 /// </summary>
0 commit comments