Considering the following:
public class Person
{
public Person(string fName, string lName)
{
this.firstName = fName;
this.lastName = lName;
}
public string firstName;
public string lastName;
}
class App
{
static void Main()
{
Person[] peopleArray = new Person[3]
{
new Person("John", "Smith"),
new Person("Jim", "Johnson"),
new Person("Sue", "Rabon"),
};
// select lastName from peopleArray where firstName like '%'J'%'
}
}
Using LINQ, how can express this:
select lastName from peopleArray where firstName like '%'J'%'
I want to print the lastnames of all person having “J” in their firstname.
I find it hard to express it in LINQ. Help Please….
1 Answer