From 6aeffa85ee76d787baa4a70411a530a0c18ccc0f Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Thu, 13 Feb 2020 15:36:04 +0100 Subject: [PATCH] - add function to convert enumberable to gBase string --- GBase/Helpers/Enumerables.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 GBase/Helpers/Enumerables.cs diff --git a/GBase/Helpers/Enumerables.cs b/GBase/Helpers/Enumerables.cs new file mode 100644 index 0000000..097eb1a --- /dev/null +++ b/GBase/Helpers/Enumerables.cs @@ -0,0 +1,32 @@ +// Author: Gockner, Simon +// Created: 2020-02-13 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System.Collections; +using System.Text; + +namespace GBase.Helpers +{ + internal static class Enumerables + { + /// + /// Convert an to a GBase + /// + /// The + /// + public static string ToGBaseString(this IEnumerable enumerable) + { + StringBuilder @string = new StringBuilder(); + foreach (var item in enumerable) + { + @string.Append($"{item},"); + } + + char lastChar = @string[^1]; + if (lastChar == ',') + @string.Remove(@string.Length - 1, 1); + + return @string.ToString(); + } + } +} \ No newline at end of file