Sorting of a List of Objects
I have a class named: Product
public class Product
{
string name;
public string Name { get { return name; } }
double price;
public double Price { get { return price; } }
string location;
public string Location { get { return location; } }
public Product(string name, double price, string location)
{
this.name = name;
this.price = price;
this.location = location;
}
}
Now I created a list of Product object
List<Product> lstProduct = new List<Product>{
new Product("WWW", 9.99, "ZZZZZZZZZ"),
new Product("AAA", 14.99, "RRRRRRRR"),
new Product("AAA", 12.99, "AAAAAAA"),
new Product("GGG", 13.69, "WWWWWWWWWWWWWWW"),
new Product("GGG", 13.99, "NNNNNNNN"),
new Product("KKK", 10.99, "TTTTTTTTTTTTTTTT")
};
Then, I need to sort them firstly by Name and then bind into a DataGrid.
Thanks in advance