- 网站二级域名用.net 2.0实现方案
- 为什么老出现XXX函数未定义错误?
- utf8mb4和utf8mb3区别
- IIS访问网站的用户过多的解决方法
- blockquote标签的用途有哪些?
- 移动控件的自定义属性
- 热搜关键词是什么意思?
- ASP.NET Core 的 WebApplication 类和 WebApplicationBuilder 类
- wwww
- CSS中的“>”符号作用
邮箱:
手机:15383239821
c#中list.Find、 list.FindAll 、list.FindIndex用法

protected void Page_Load(object sender, EventArgs e)
{
List<User> list = new List<User>();
list.Add(new User(1, "testOne"));
list.Add(new User(2, "testTwo"));
list.Add(new User(3, "testThree"));
list.Add(new User(4, "testTwo"));
User user1 = list.Find(p =>p.name.Equals("testTwo"));
string aa= list.Find((User uu) => uu.name.Equals("testTwo")).ToString();
List<User> listfind = list.FindAll(p => p.name == "testTwo");
for(int i=0;i<listfind.Count;i++)
{
Response.Write(listfind[i].id + "," + listfind[i].name + "<br>");
}
Response.Write("<br><br>");
int imatch = list.FindIndex(a => a.name == "testThree"); //查找是否存在叫"testThree"的人,返回list中有位置,注意:这里的位置并不是数据的id
Response.Write("所在位置为:"+imatch);
}
class User
{
int _id;
string _name;
public User(int id, string name)
{
_id = id;
_name = name;
}
public int id
{
set { _id = value; }
get { return _id; }
}
public string name
{
set { _name = value; }
get { return _name; }
}
}
-
2025-10-16Autofac是什么?
-
2012-07-02说说网站如何优化才有好的排名的
-
2011-03-06如果空间可以绑定多个域名,但不支持绑定子目录,实现跳转的方法
-
2023-10-13网站404页面一般放在那里
-
2019-11-21C#实例化类的方式
-
2024-06-27单页面应用是什么?优缺点?
