i have class like below
class Person
{
public string Name{get;set;}
public string Surname{get;set;}
public int Age{get; set;}
}
I have a list like this
List<Person> persons = new List<Person>();
Then there is a method
public Person SelectPerson(string name)
{
var q = from p in persons where p.Name==name select p;
return (Person)q;
}
But it gives an error like this
Unable to cast object of type ‘WhereListIterator`1[PrsLst.Person]’ to type ‘PrsLst.Person’.
SO what is the problem and can u help me to fix it.
1 Answer