using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.Collections; using System.IO;namespace CSharpTest { class A { public int nu; public string ch; public A(int a, string c) { nu = a; ch = c; } } class B { static void Main() { List<A> list1 = new List<A>(); list1.Add(new A(1, "a")); list1.Add(new A(1, "b")); list1.Add(new A(2, "b")); List<A> list2 = new List<A>(); list2.Add(new A(1, "a")); list2.Add(new A(1, "b")); list2.Add(new A(2, "b")); list2.Add(new A(4, "c")); foreach (A m in list2) { if (!exists(list1, m)) Console.WriteLine("{0} {1}", m.nu, m.ch); } } static bool exists(List<A> list, A a) { foreach (A b in list) { if (b.ch == a.ch && b.nu == a.nu) return true; } return false; } }}
if(list1[i]==list[i])
{
remove()
}
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.IO;namespace CSharpTest
{ class A
{
public int nu;
public string ch;
public A(int a, string c)
{
nu = a;
ch = c;
}
} class B
{ static void Main()
{
List<A> list1 = new List<A>();
list1.Add(new A(1, "a"));
list1.Add(new A(1, "b"));
list1.Add(new A(2, "b"));
List<A> list2 = new List<A>();
list2.Add(new A(1, "a"));
list2.Add(new A(1, "b"));
list2.Add(new A(2, "b"));
list2.Add(new A(4, "c"));
foreach (A m in list2)
{
if (!exists(list1, m))
Console.WriteLine("{0} {1}", m.nu, m.ch);
}
} static bool exists(List<A> list, A a)
{
foreach (A b in list)
{
if (b.ch == a.ch && b.nu == a.nu) return true;
}
return false;
}
}}