I have a List
with class name Product
and I want to know the index of the element which has the maximum value?
class Product
{
public int ProductNumber { get; set; }
public int ProductSize { get; set; }
}
List<Product> productList = new List<Product>();
int Index = productList.Indexof(productList.Max(a => a.ProductSize));
I have tried this but it is not getting answer! And getting an error:
"Unable to Cast as Product"