如何将数据加载到通用列表 [英] How to Load the data to generic List

查看:80
本文介绍了如何将数据加载到通用列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经创建了一个名称列表.在此列表中包含很多名称.有些名称也包含重复.所以我需要找到名称的索引.例如,名称是Raju.它重复了5次,我想找到每个名字的索引.



这里的详细编码
1.

Hi
I have created one Name list. In this list contains lot of names. some names are contains repeated also. so i need to find the indexs of the names. for example Name is Raju. its repeat in 5 times i wanna find the index of every name.



here the detail coding
1.

List<string> listLog = listLog1.GetRange(sindexs, eindex);


在这种情况下,"Listlog"包含所有名称.
2.列出< string> listLog1 =(List< string>)(从项目中的项目,其中item.StartsWith(发生患者配置更改")选择项目).ToList();
在这一行中,我可以找到多少重复.
所以我想知道如何查找每个发生的患者配置更改"的索引.
帮帮我..


in this case the "Listlog" contains all Names.
2.List<string> listLog1 = (List<string>)(from item in values where item.StartsWith("Patient Configuration Change Occurred") select item).ToList();
in this line i can find how many repeatations.
So i wanna know how to find the indexs of each and every "Patient Configuration Change Occurred"
Help me..

推荐答案

有关更多详细信息,请参见 ^ ]方法.它具有返回第一个和下一个的版本-通过使用前一个的索引加一个作为下一个的起始地址.

另外,您也可以使用Linq通过一个简单的Select或Where调用来生成列表.
With out more detail, look at the List.IndexOf[^] method. It has versions to return the first, and the next - by using the index of the previous plus one as the start address of the next.

Alternatively, you could use Linq to produce the list with a simple Select or Where call.


这篇关于如何将数据加载到通用列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆