Check list contains the values of another list

Following example returns the list contains the values of another list

using System;
using System.Collections.Generic;
using System.Linq;

namespace ZeroToCSharp {
    class Program {
        static void Main(string[] args) {
            string[] filter = new string[] { "Ape", "Bird", "Cat", "Dolphin", "Eagle" };
            List<string> animals = new List<string>() { "Bison", "Ape", "Pony", "Ape", "Monkey", "Deer", "Cat", "Cow" };
            var result = animals.Where(x => filter.Contains(x)).ToList();

            //To print output
            result.ForEach(x => Console.WriteLine(x));
            Console.ReadKey();
        }
    }
}

Output:

Ape
Ape
Cat

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x