1. Write a rule method first
private bool check(string str){ return ("xxx"); }
2. Write another Predicate
Predicate<string> predicate=new Predicate<string>(check));
If the logic is not complicated, you can write it like this
private void OpenMenu(GameObject gob){ Predicate<string> predicate=new Predicate<string>(s =>() ); int i=_nameList.FindIndex(predicate); }
Predicate can be simplified
Predicate<string> predicate = s => ();
Just put it in the list
int index=_nameList.FindIndex(s => ());
No found Return -1
Summarize
The above is the editor’s introduction to how to find the index of elements in the list by the C# lambda expression application. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!