List finding element after typing one letter of it's name, list of Images

Hi, can someone guide me on how to find in a List of objects, doesn’t matter what kind of objects, it’s not relevant to the topic.

I have a List of images each of which has its own name, it’s shown in UI, and there is an Input Field while typing in the input field objects appear and disappear after typing their names, all I have managed but the question is how to filter those objects after typing in the input field even one of its letter, in example, red square, and it’s not matter am I willing to type r,e,d, each of letters shows this or other objects containing letters like in example. How to filter a list like so?
Any help?

LINQ:

var results = yourList.Where(x => x.StartsWith("r")).ToList();
var results = yourList.Where(x => x.Contains("r")).ToList();
var results = yourList.Where(x => x.EndsWith("r")).ToList();

// Starts with "R" or "r" (case insensitive)
var results = yourList.Where(x => x.StartsWith("r", StringComparison.OrdinalIgnoreCase)).ToList();

Oh, would it be so simple…
Thanks…
I’ll test it but it seems to be ok…

Yes, now I do remember why I couldn’t solve it…
Just like I mentioned List contains Image types of objects and it’s about more or less like in the Nad_B answer but it’s getting harder with every solution tried…

Then just use x.name?

1 Like

His answer wasn’t a complete solution but more of an example. LINQ needs to be told the field.

var results = yourList.Where(x => x.name.StartsWith("r", StringComparison.OrdinalIgnoreCase)).ToList();
1 Like

Indeed, but after a little tune-up, the first answer gave the same result, anyway thanks for help guys. The problem seems to be solved finally…

Geez, how to mark the post as “Solved”?