33 lines
822 B
C#
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);
|
|
}
|
|
}
|
|
} |