I have a list with elements where an element is a class of some string and datetime values. I have the situation that some elements in the list are the same, but I only want the unique entries. I have tried the following but to no results. And I have verified that there are double entries. These are some snipets:
public class RunningProcess
{
public string PSComputerName { get; set; }
public string ProcessName { get; set; }
public string ProcessID { get; set; }
public string CommandLine { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
public string Username { get; set; }
public string RemoteIP { get; set; }
}
now:
l_runningprocesses = l_runningprocesses.Distinct().ToList();
or
var unique_items = new HashSet<RunningProcess>(l_runningprocesses);
or
List<RunningProcess> uniques = new List<RunningProcess>();
foreach (RunningProcess item in l_runningprocesses)
{
if (!uniques.Contains(item)) uniques.Add(item);
}
All the same. I keep the doubles. Any ideas anyone??
Regards,
Ronald