I want to create a list which will hold two int values lets say it arrfirst
and another list that will hold lists of arrfirst
, lets say it arrsecond
then check if arrsecond
contains a defined arrfirst
. Now i created lists but when i try to use .Contains
it doesn't work.
List<List<int>> Eklenenler = new List<List<int>>();
for (int i = 0; i < YourTable.Rows.Count; i++)
{
prjAd = YourTable.Rows[i].Field<string>("F1");
if (prjAd != "Servis Adresi")
{
wesAd = YourTable.Rows[i].Field<string>("F2");
RowPrj = tbProjeler.AsEnumerable().Where(r => r.Field<string>("prjAd") == prjAd).FirstOrDefault();
RowWes = tbServisler.AsEnumerable().Where(k => k.Field<string>("wesAd") == wesAd).FirstOrDefault();
prjId = RowPrj.Field<int>("prjId");
wesId = RowWes.Field<int>("wesId");
List<int> temp = new List<int>();
temp.Add(prjId);
temp.Add(wesId);
if (!Eklenenler.Contains(temp))
{
sqlExProjeEkle = "INSERT INTO NLK_PRJ_Webservisler (prjId,wesId) Values (" + prjId + "," + wesId + ")";
dco.Execute(sqlExProjeEkle);
Eklenenler.Add(temp);
}
else
{
}
}
}
This is my code. When i debugging, i can see temp
values are right and also at second loop, temp
is in Eklenenler
list but it always goes in if
block. For example, first loop shows temp[0]=36
and temp[1]=42
goes in if block and at second loop again temp[0]=36
and temp[1]=42
also Eklenenler[0][0]=36
and Eklenenler[0][1]=42
so it contains temp but it still goes in. How can i solve this problem and why this returns false and can't find this temp
in Eklenenler
. Thank you.
if(row.SequenceEquals(anotherRow))
?