I have the following method that load products on a DataGridView
private void LoadProducts(List products)
{
Source.DataSource = products;
So how can I cast the DataSource to an List?
You have plenty of options
var products = (List)Source.DataSource; // products if of type List
or
List
or
List products = ((IEnumerable)Source.DataSource).OfType().ToList();
or
List products = new List();
((IEnumerable)Source.DataSource).AsEnumerable().ToList().ForEach( x => products.Add( (object)x));