Exemple #1
0
        static void Main(string[] args)
        {
            var personList = People.GetPeople();

            Console.WriteLine("Please select a method for print. 1, 2, 3 or 4.");
            var choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                formatPerson = p => p.ToString();
                break;

            case "2":
                formatPerson = p => p.LastName.ToUpper();
                break;

            case "3":
                formatPerson = p => p.FirstName.ToLower();
                break;

            case "4":
                formatPerson = p => string.Format("{0} {1}", p.FirstName, p.LastName);
                break;
            }

            foreach (var p in personList)
            {
                Console.WriteLine(p.ToString(formatPerson));
            }

            Console.ReadLine();
        }
Exemple #2
0
 private void ProcessDataButton_Click(object sender, RoutedEventArgs e)
 {
     OutputList.Items.Clear();
     if (StringExpander.IsExpanded)
     {
         AssignDelegate();
         foreach (Person person in PersonListBox.Items)
         {
             OutputList.Items.Add(person.ToString(formatPerson));
         }
     }
     if (ActionExpander.IsExpanded)
     {
         AssignAction();
         var people = People.GetPeople();
         if (actOnPeople != null)
         {
             actOnPeople(people);
         }
     }
 }
Exemple #3
0
 public MainWindow()
 {
     InitializeComponent();
     PersonListBox.ItemsSource = People.GetPeople();
 }