How to get distinct List from a custom list?

Viewed 394

I am using c# framework 3.5 ..

my class here

  public class KonumBilgisi
{

    public string Enlem { get; set; }
    public string Boylam { get; set; }
    public string KonumAdi { get; set; }
    public DateTime Tarih { get; set; }
    public byte SucTuruId { get; set; }

}

I have a list

List konumlar;

well, I want to get items that equal their enlem and boylam variables each other..

As you see on the photo below

enter image description here

I want to compate enlem and boylam and if its the equal I want to get them to different list..

I can do that with a loop but want to use LINQ but i couldnt do that. I used groupby but it doesnt wrong..

   var distinctList = konumlar.GroupBy(x => x.Enlem)
                        .Select(g => g.First())
                        .ToList().GroupBy(s=>s.Boylam).Select(g => g.First())
                        .ToList();

EDIT Actually I couldnt explain my quesion well..

maybe distinct is not right word.. I want to seperate items which are equals each other..

such as:

I will take pendik items in one list and others will be in konumlar but pendik items will be removed from konumlar list

EDIT 2

Okay I want to seperate the list like that

enter image description here

enter image description here

3 Answers
Related