-1
public List<Video> filtra_data(string date)
            {
                List<Video> lista_filtrata = new List<Video>();
                for (int i = 0; i < listavideo.Count; i++)
                {
                    if (listavideo[i].Data.Contains(date) == true)
                        lista_filtrata.Add(listavideo[i]);
                }
                return lista_filtrata;
            }

i made this method to filter a list of movies using the date as parameter but when, on the form, i put the input in the textbox and i press the button it raises an exception on the for: object reference not set to an instance of an object, any ideas? thank you everyone

Fante
  • 9
  • 1

1 Answers1

2

Try to trace your method,check listavideo first whether its fill from your data layer or not, secondly there is a better way to do so,

public List<Video> filtra_data(string date)
 {
    Return listavideo.Where(m=>m.Data.Contains(date)).ToList()
 }
Behzad
  • 857
  • 1
  • 8
  • 27