📌  相关文章
📜  列表中项目的索引 C# 代码示例

📅  最后修改于: 2022-03-11 14:48:52.204000             🧑  作者: Mango

代码示例1
List strings = new List(){"bob","ate","an", "apple"};
strings.IndexOf("bob");
//returns 0 
strings.IndexOf("an");
//returns 2
strings.IndexOf("apple");
//returns 3
strings.IndexOf("banana");
//returns -1
//Because banana is not in the list, IndexOf() returns -1