Skip to content

Commit c2910f4

Browse files
committed
New function
Added new function to combine a list of strings into a single string where each value gets its own line
1 parent 2857a52 commit c2910f4

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# ZimLabs.Core
2+
23
Core library with some helpfull functions
4+
5+
## Changelog
6+
7+
- 2.3.0
8+
9+
Added new function `CombineString(param string[] values)` which converts a list of string into a single string where every value gets its own line.
10+
11+
**Example**
12+
13+
```csharp
14+
var result = Core.CombineString("Value1", "Value2", "Value3");
15+
16+
Console.WriteLine(result);
17+
18+
// Result
19+
// ------
20+
// Value1
21+
// Value2
22+
// Value3
23+
```

src/ZimLabs.CoreLib/ZimLabs.CoreLib/Core.cs

+29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Text;
23
using ZimLabs.CoreLib.Common;
34
using ZimLabs.CoreLib.DataObjects;
45

@@ -36,4 +37,32 @@ public static bool MatchFilter(string value, FilterEntry filter)
3637
_ => false
3738
};
3839
}
40+
41+
/// <summary>
42+
/// Combines a list of strings to a single string where each entered value gets its own line
43+
/// <example>
44+
/// <code>
45+
/// var result = Core.CombineString("Value1", "Value2", "Value3");
46+
///
47+
/// Console.WriteLine(result);
48+
///
49+
/// // Result
50+
/// Value1
51+
/// Value2
52+
/// Value3
53+
/// </code>
54+
/// </example>
55+
/// </summary>
56+
/// <param name="values">The list with the values</param>
57+
/// <returns>The values as single string. Each value in its own line</returns>
58+
public static string CombineString(params string[] values)
59+
{
60+
var sb = new StringBuilder();
61+
foreach (var value in values)
62+
{
63+
sb.AppendLine(value);
64+
}
65+
66+
return sb.ToString();
67+
}
3968
}

src/ZimLabs.CoreLib/ZimLabs.CoreLib/ZimLabs.CoreLib.csproj

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@
1414
<PackageTags>helper, extensions</PackageTags>
1515
<PackageReleaseNotes>Added filter functions</PackageReleaseNotes>
1616
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
17-
<AssemblyVersion>2.2.0</AssemblyVersion>
18-
<FileVersion>2.2.0</FileVersion>
19-
<Version>2.2.0</Version>
17+
<AssemblyVersion>2.3.0</AssemblyVersion>
18+
<FileVersion>2.3.0</FileVersion>
19+
<Version>2.3.0</Version>
2020
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2121
<GenerateDocumentationFile>True</GenerateDocumentationFile>
22+
<PackageReadmeFile>README.md</PackageReadmeFile>
2223
</PropertyGroup>
2324

2425
<ItemGroup>
2526
<None Include="..\..\..\Logo.png">
2627
<Pack>True</Pack>
2728
<PackagePath>\</PackagePath>
2829
</None>
30+
<None Include="..\..\..\README.md">
31+
<Pack>True</Pack>
32+
<PackagePath>\</PackagePath>
33+
</None>
2934
</ItemGroup>
3035

3136
</Project>

0 commit comments

Comments
 (0)