社区
C#
帖子详情
关于List<>.FindIndex的问题。
younker
2006-12-20 05:09:14
假设有一个list<string>, 现在要查找里面是否存在字符串'ABC',
使用List<string>.FindIndex()怎么实现?
...全文
1909
5
打赏
收藏
关于List<>.FindIndex的问题。
假设有一个list, 现在要查找里面是否存在字符串'ABC', 使用List.FindIndex()怎么实现?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用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";} )
人工智能Python核心知识点_
list
列表
List
列表是 Python 中使用最频繁的数据...本课程主要讲解
list
列表的特性、定义、以及字典的读取、新增、修改、删除元素、相加和数乘等知识点,学习本课程能够轻松掌握
list
列表相关知识点并灵活的运用到实际的
问题
中来。
c#
List
<T>.Find
Index
方法
List
.Find
Index
方法 (1)Find
Index
(Int32, Int32, Predicate) 代指:搜索与指定谓词所定义的条件相匹配的一个元素,并返回
List
中从指定的索引开始、包含指定元素个数的元素范围内第一个匹配项的从零开始的索引。...
List
.Find
Index
方法 (Predicate
)
搜索与指定谓词所定义的条件相匹配的元素,并返回整个
List
<T>中第一个匹配元素的从零开始的索引。 命名空间:System.Collections.Generic程序集...public int Find
Index
( Predicate<T> match ) ...
C#
List
<T>的 Find方法、FindLast方法、FindAll方法、Find
Index
方法
学号:2019 4、使用Find
Index
public int Find
Index
(Predicate match) 找到学生姓名为“学生15”的序号 int result4 =
list
.Find
Index
((Student s) => s.NAME == "学生15"); Console.WriteLine(@"序号:{0}", result...
c#中
List
find使用示例(转)
public int Find
Index
(int
index
, Predicate<T> match); public int Find
Index
(int
index
, int count, Predicate<T> match); public int FindLast
Index
(Predicate<T> match); public int ...
C#
110,561
社区成员
642,566
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章