Files
mpv.net/mpvnet/Extensions.cs
stax76 c4cf7ed11b -
2017-09-02 04:35:24 +02:00

33 lines
822 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mpvnet
{
public static class Extensions
{
public static string Join(this IEnumerable<string> instance, string delimiter, bool removeEmpty = false)
{
if (instance == null)
return null;
bool containsEmpty = false;
foreach (var i in instance)
{
if (string.IsNullOrEmpty(i))
{
containsEmpty = true;
break;
}
}
if (containsEmpty && removeEmpty)
instance = instance.Where(arg => !string.IsNullOrEmpty(arg));
return string.Join(delimiter, instance);
}
}
}