Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 c# 中使用列表,我试图在字符串中查找部分或完整结果
List<GoogleMusicSong> artistname = gplaying.FindAll(delegate(GoogleMusicSong er) { return er.Artist == Txt_Search.Text; });
所以我想找到 txt_serch.txt 的所有匹配项,例如,如果我搜索部落,我希望它找到“A Tribe Called Quest”的结果
谢谢
你的意思是这样的:
var artistName = gplaying.FindAll(er => er.Artist.Contains(Txt_Search.Text));
请记住,这将导致搜索区分大小写。如果您想以不区分大小写的方式进行搜索,则必须使用以下内容:
var artistName = gplaying.FindAll(er => er.Artist .IndexOf(Txt_Search.Text, StringComparison.InvariantCultureIgnoreCase) > 0);