You are designing a windows forms application. You have added a list box control and a button control to it. The listbox is already populated with some items. Upon clicking on the button the items should be sorted in the descending order. Which one will you go for(most optimized)?

 Posted by Niladri.Biswas on 2/3/2013 | Category: C# Interview questions | Views: 4737 | Points: 40
Select from following answers:
  1. List<string> sortedItems = new List<string>();Enumerable.Range(0, lstItems.Items.Count).ToList.ForEach(i => sortedItems.Add(lstItems.Items[i].ToString()));lstItems.Items.Clear();lstItems.Items.AddRange(sortedItems.OrderBy(o => o).ToArray());
  2. lstItems.IsSorted = true;
  3. lstItems.Items.Sorted = true;
  4. lstItems.Sorted = true;
  5. All Above

Show Correct Answer

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response