在C#中,可以使用List
List<int> numbers = new List<int> { 3, 1, 4, 1, 5, 9, 2, 6 };
numbers.Sort();
List<string> names = new List<string> { "Alice", "Bob", "Charlie", "David" };
names.Sort((x, y) => x.Length.CompareTo(y.Length));
List<int> numbers = new List<int> { 3, 1, 4, 1, 5, 9, 2, 6 };
var filteredNumbers = numbers.Where(n => n % 2 == 0).ToList();
List<string> names = new List<string> { "Alice", "Bob", "Charlie", "David" };
var foundName = names.Find(n => n.StartsWith("C"));
var foundNames = names.FindAll(n => n.Length == 4);
通過這些技巧,可以方便地對列表控件進行排序與篩選操作,實現更靈活的數據展示與處理功能。