Skip to content

Commit

Permalink
StringBuilderExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Nov 4, 2024
1 parent 5019840 commit 3981033
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions CSUtilities/CSUtilities.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Compile Include="$(MSBuildThisFileDirectory)EnvironmentVars.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IDictionaryExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ObjectExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\StringBuilderExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Text\CodePage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\DefaultEndianConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\EndianConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion CSUtilities/Extensions/IDictionaryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace CSUtilities.Extensions
{
/// <summary>
/// Estensions for <see cref="IDictionary{TKey, TValue}"/>
/// Extensions for <see cref="IDictionary{TKey, TValue}"/>
/// </summary>
public static class IDictionaryExtension
{
Expand Down
39 changes: 39 additions & 0 deletions CSUtilities/Extensions/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSUtilities.Extensions
{
/// <summary>
/// StringBuilder utility extensions.
/// </summary>
#if PUBLIC
public
#else
internal
#endif
static class StringBuilderExtensions
{
#if NETFRAMEWORK
/// <summary>
///
/// </summary>
public static StringBuilder AppendJoin<T>(this StringBuilder sb, string? separator, IEnumerable<T> values)
{
separator ??= string.Empty;

for (var i = 0; i < values.Count(); i++)
{
if (i > 0)
{
sb.Append(separator);
}

sb.Append(values.ElementAt(i));
}

return sb;
}
#endif
}
}

0 comments on commit 3981033

Please sign in to comment.