I am using LINQ .Find() and it’s not stopping when it finds a match. I have:
List<ipFound> ipList = new List<ipFound>();
ipFound ipTemp = ipList.Find(x => x.ipAddress == srcIP);
if (ipTemp == null) {
// this is always null
}
public class ipFound
{
public System.Net.IPAddress ipAddress;
public int bytesSent;
public int bytesReceived;
public int bytesTotal;
}
Any ideas? I’m going nuts over here.
Thanks!
You need to use
.Equalsinstead of==.In the sample above,
a == bisFalsebecause those are two different objects. However,a.Equals(b)isTruebecause they have equal values.