list.Contain 및 list.FindIndex () 사용 로깅

2682 단어 contain
List<Plan> Plans = new List<Plan>();

//

//Plan PlanID 。


if (Plans.Contains<Plan>(changedPlan, Comparers.Default)){}

// Plans changedPlan Plan。

//( PlanID 。 )

// Comparers.Default 。



public class Comparers : IEqualityComparer<Plan>

{

// IEqualityComparer<Plan>

public static Comparers Default = new Comparers();

#region IEqualityComparer<Plan>

public bool Equals(Plan x, Plan y)
{

return x.PlanID.Equals(y.PlanID);// PlanID

}

public int GetHashCode(Plan obj)

{

return obj.PlanID.GetHashCode();

}

#endregion

}

List<Plan> Plans = new List<Plan>();

Plans.FindIndex(new Predicate<Plan>(findPlan));// Plans PlanID Plan Index

bool findPlan(Plan p)// ( p Plans , p.PlanID PlanID )

{

 return p.PlanID.Equals(PlanID);

}

좋은 웹페이지 즐겨찾기