社区
C#
帖子详情
关于List<>.FindIndex的问题。
younker
2006-12-20 05:09:14
假设有一个list<string>, 现在要查找里面是否存在字符串'ABC',
使用List<string>.FindIndex()怎么实现?
...全文
1928
5
打赏
收藏
关于List<>.FindIndex的问题。
假设有一个list, 现在要查找里面是否存在字符串'ABC', 使用List.FindIndex()怎么实现?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
liujia_0421
2006-12-21
打赏
举报
回复
这个意思??
List<string> list = new List<string>();
list.Add("aaa");
list.Add("bbb");
list.Add("ABC");
//指定一个变量
string str = "ABC";
//查换变量
int index = list.FindIndex(delegate(string s) { return s == str; });
Console.WriteLine(index);
输出:
2
liujia_0421
2006-12-21
打赏
举报
回复
for example;
List<string> list = new List<string>();
list.Add("aaa");
list.Add("bbb");
list.Add("ABC");
int index=list.FindIndex(delegate(string s) { return s == "ABC"; });
Console.WriteLine(index);
输出:
2
younker
2006-12-21
打赏
举报
回复
我不是要找ABC,而是找等于ABC的这个变量,比如有个s=“ABC”, 如何在List<>中找到s呢?
wdy9927
2006-12-20
打赏
举报
回复
??
mark
runrunrun
2006-12-20
打赏
举报
回复
List<string>.FindIndex( delegate(string s){ return s=="ABC";} )
c#
List
<T>.Find
Index
方法
List
.Find
Index
方法 (1)Find
Index
(Int32, Int32, Predicate) 代指:搜索与指定谓词所定义的条件相匹配的一个元素,并返回
List
中从指定的索引开始、包含指定元素个数的元素范围内第一个匹配项的从零开始的索引。 例如:public int Find
Index
(int start
Index
, int count, Predicate match); 其中 int start
Index
代表从零开始的搜索的起始索引。 int count 代表要搜索的
List
.Find
Index
方法 (Predicate
)
搜索与指定谓词所定义的条件相匹配的元素,并返回整个
List
<T>中第一个匹配元素的从零开始的索引。 命名空间:System.Collections.Generic程序集:mscorlib(mscorlib.dll 中) 语法 public int Find
Index
( Predicate<T> match ) ...
C#
List
<T>的 Find方法、FindLast方法、FindAll方法、Find
Index
方法
一个简单类 //学生 public class Student { private int id;//id private string name;//姓名 private int student_//学号 public int ID { get { return id; } set { id = value; } public string NAME { get { return name; }
c#中
List
find使用示例(转)
转自:http://blogs.msdn.com/b/kcwalina/archive/2004/06/22/162533.aspxGenerics and Anonymous Methods/Del
java泛型、
List
、Array
List
总结(
List
<String>
list
= new Array
List
<String>())
java泛型、
List
、Array
List
总结(
List
list
= new Array
List
()) 在学习java+appium自动化测试时,遇到如下代码,对于其中泛型、
List
、Array
List
不是很懂,查阅资料后,做如下总结 ‘’’ public Array
List
getAll(){ Array
List
array=new Array
List
(); for(WebElement e: Driver.getCurrentDriver().findElements(By.id(“stockNam
C#
111,093
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章