53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace 数组整合
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
List<String> A = new List<string> { "A", "C", "E", "G", "I", "J", "L" };
|
|
List<String> B = new List<string> { "A", "B", "C", "D", "E", "F", "G" };
|
|
List<String> C = getResult(A, B);
|
|
printList(A);
|
|
printList(B);
|
|
printList(C);
|
|
Console.Read();
|
|
}
|
|
|
|
static void printList(List<String> list)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (var item in list)
|
|
{
|
|
sb.Append(item + " ");
|
|
}
|
|
Console.WriteLine(sb.ToString());
|
|
}
|
|
|
|
static List<String> getResult(List<String> notExist, List<String> exist)
|
|
{
|
|
List<String> result = new List<string>();
|
|
foreach (var e in exist)
|
|
{
|
|
Boolean has = false;
|
|
foreach (var ne in notExist)
|
|
{
|
|
if (ne == e)
|
|
{
|
|
has = true;
|
|
}
|
|
}
|
|
if(!has){
|
|
result.Add(e);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|