Skip to content

Commit

Permalink
New function
Browse files Browse the repository at this point in the history
Added new function to combine a list of strings into a single string where each value gets its own line
  • Loading branch information
InvaderZim85 committed Mar 16, 2023
1 parent 2857a52 commit c2910f4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# ZimLabs.Core

Core library with some helpfull functions

## Changelog

- 2.3.0

Added new function `CombineString(param string[] values)` which converts a list of string into a single string where every value gets its own line.

**Example**

```csharp
var result = Core.CombineString("Value1", "Value2", "Value3");

Console.WriteLine(result);

// Result
// ------
// Value1
// Value2
// Value3
```
29 changes: 29 additions & 0 deletions src/ZimLabs.CoreLib/ZimLabs.CoreLib/Core.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Text;
using ZimLabs.CoreLib.Common;
using ZimLabs.CoreLib.DataObjects;

Expand Down Expand Up @@ -36,4 +37,32 @@ public static bool MatchFilter(string value, FilterEntry filter)
_ => false
};
}

/// <summary>
/// Combines a list of strings to a single string where each entered value gets its own line
/// <example>
/// <code>
/// var result = Core.CombineString("Value1", "Value2", "Value3");
///
/// Console.WriteLine(result);
///
/// // Result
/// Value1
/// Value2
/// Value3
/// </code>
/// </example>
/// </summary>
/// <param name="values">The list with the values</param>
/// <returns>The values as single string. Each value in its own line</returns>
public static string CombineString(params string[] values)
{
var sb = new StringBuilder();
foreach (var value in values)
{
sb.AppendLine(value);
}

return sb.ToString();
}
}
11 changes: 8 additions & 3 deletions src/ZimLabs.CoreLib/ZimLabs.CoreLib/ZimLabs.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@
<PackageTags>helper, extensions</PackageTags>
<PackageReleaseNotes>Added filter functions</PackageReleaseNotes>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>2.2.0</AssemblyVersion>
<FileVersion>2.2.0</FileVersion>
<Version>2.2.0</Version>
<AssemblyVersion>2.3.0</AssemblyVersion>
<FileVersion>2.3.0</FileVersion>
<Version>2.3.0</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\..\Logo.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>

0 comments on commit c2910f4

Please sign in to comment.