add ToNullTerminatedArray function (for P/Invoke interop)

This commit is contained in:
Michael Becker 2021-07-25 08:48:25 -04:00
parent 96c4c6f217
commit 95495ac334
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C

View File

@ -62,5 +62,16 @@ namespace MBS.Framework.Collections.Generic
list.Add(item);
}
}
public static T[] ToNullTerminatedArray<T>(this IEnumerable<T> enumerable) where T : class
{
List<T> list = new List<T>();
foreach (T name in enumerable)
{
list.Add(name);
}
list.Add(null);
return list.ToArray();
}
}
}