Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Animal
- {
- public string nome {get; set;}
- }
- public class Product
- {
- public int id {get; set;}
- public string name {get; set;}
- public Product(int _id, string _name)
- {
- id = _id;
- name = _name;
- }
- }
- private static ObservableCollection<Product> products = new ObservableCollection<Product>
- {
- new Product(1, "Book"),
- new Product(2, "Desktop Computer"),
- new Product(3, "Notebook"),
- new Product(4, "Netbook"),
- new Product(5, "Business Software"),
- new Product(6, "Antivirus Software"),
- new Product(7, "Game Console"),
- new Product(8, "Handheld Game Console"),
- new Product(9, "Mobile Phone"),
- new Product(10, "Multimedia Software"),
- new Product(11, "PC Game")
- };
- void Main()
- {
- IEnumerable<Product> orderByName = products.OrderBy(x => typeof(Product).GetProperty("name").GetValue(x, null));
- Console.WriteLine(orderByName);
- }
- // Define other methods and classes here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement