c.FindItemsNotInSmallerStringArray
Tue Aug 15 2023 13:37:35 GMT+0000 (Coordinated Universal Time)
Saved by
@rick_m
#c#
/// <summary>
/// If you want to find items in larger list that are not present in small list
/// </summary>
/// <param name="largerList">"A","B","C"</param>
/// <param name="smallerList">"A"</param>
/// <returns>"B","C"</returns>
public static string[] FindItemsNotInSmallerStringArray(this string[] largerList, string[] smallerList) => largerList.Except(smallerList).ToArray();
content_copyCOPY
string[] largerList = new string[] { "A","B","C" };
string[] smallerList = new string[] { "A" };
string[] missing = largerList.FindItemsNotInSmallerStringArray(smallerList);
string missingServices = string.Join(", ", missing);
Console.WriteLine("missingServices:{0}", missingServices);
Comments