I have a question about deleting duplicates from array list. I want to join two strings from two tables and then split it. Compare the string from one table with others, if duplicates exist then delete it. I did it with this code but i'm asking if there is another faster and shorter way to do it?
table1: String a = "abc"
table2: String b = "def,abc,okl"
Result: "abc,def,okl"
My code:
foreach(DataRow tr in transM.Rows)
{
foreach(DataRow tb in tableDGV1.Rows)
{
if (tr["ID"].ToString() == tb["ID"].ToString())
{
string trMitter = tr["Tr"].ToString() + "," + tb["Tr"].ToString();
string[] trSplit = trMitter.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
List<string> listTr = new List<string>(trSplit);
for (int k = 0; k < listTr.Count; k++)
{
for (int g = k + 1; g < listTr.Count; g++)
{
if (listTr[g].ToString() == listTr[k].ToString()) listTr.RemoveAt(g);
}
}
}
}
}