✅ Accsessing Method in another class by object

I have a customer class which contains the method I want to access
        public override void GetAllVichles(List<Enrollment> en)
        {
            //en.Sort();
            foreach (var enrollment in en)
            {
                foreach (var item in enrollment.Enrollments)
                {
                    if (item.CustomerInfo.FirstName == FirstName && item.CustomerInfo.LastName == LastName)
                    {
                        Console.WriteLine($"{item.CustomerInfo.FirstName} {item.VichleInfo.vichleList}");
                    };
                }
            }
        }

I want to call that method in my program.cs inside my foreach
                        Console.WriteLine("Write name of customer");
                        string customSearch = Console.ReadLine();
                        foreach (var item in vichle.vichleList)
                        {
                            if(customSearch == item.Owner.FirstName)
                            {

                            }

It is supposed to search for customers with the written name

Thanks beforehand 🙂
Was this page helpful?