Which code segment should you add to the click event handler of the Button control ?

You are developing WPF application for managing student information… btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml properties : FirstName and LastName. You create the following code segment in the constructor of..

Students = new List<Student>(
new Student[]
{
new Student() { FirstName = “Nicole”, LastName = “Holiday” },

}
);

The DataGrid control displays the list of students unsorted.

You need to ensure that the list of students is sorted by last name.

Which code segment should you add to the click event handler of the Button control ?

You are developing WPF application for managing student information… btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml properties : FirstName and LastName. You create the following code segment in the constructor of..

Students = new List<Student>(
new Student[]
{
new Student() { FirstName = “Nicole”, LastName = “Holiday” },

}
);

The DataGrid control displays the list of students unsorted.

You need to ensure that the list of students is sorted by last name.

Which code segment should you add to the click event handler of the Button control ?

A.
IEnumerable<Student> sortedStudents = Students.OrderBy(s => s.LastName);
dgStudents.ItemsSource = sortedStudents;

B.
IEnumerable<Student> sortedStudents = Students.OrderBy(s => s.LastName).ToList();
dgStudents.ItemsSource = sortedStudents;

C.
Students.Sort();
dgStudents.ItemsSource = Students;

D.
Students.Reverse();
dgStudents.ItemsSource = Students;



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Mr ijs

Mr ijs

Full question text:

You are developing a Windows Presentation Foundation (WPF) application for managing student information. You place a Button control named btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml file. You create a Student class with two properties: FirstName and LastName. You create the following code segment in the constructor of the main window.

Students = new List(
new Student[]
{
new Student() { FirstName = “Nicole”, LastName = “Holiday” },

}
);

The DataGrid control displays the list of students unsorted.

You need to ensure that the list of students is sorted by last name.

Which code segment should you add to the click event handler of the Button control?