Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# aaray数据差异 #94

Open
landv opened this issue Aug 15, 2024 · 0 comments
Open

C# aaray数据差异 #94

landv opened this issue Aug 15, 2024 · 0 comments

Comments

@landv
Copy link
Owner

landv commented Aug 15, 2024

class Program
{
	static void Main()
	{
		// 示例数组
		string[] array1 = { "file1.pdf", "file2.pdf", "file3.pdf" };
		string[] array2 = { "file2.pdf", "file3.pdf", "file4.pdf" };

		// 找出在 array1 中但不在 array2 中的元素
		var onlyInArray1 = array1.Except(array2);

		// 找出在 array2 中但不在 array1 中的元素
		var onlyInArray2 = array2.Except(array1);

		Console.WriteLine("Only in array1:");
		foreach (var item in onlyInArray1)
		{
			Console.WriteLine(item);
		}

		Console.WriteLine("\nOnly in array2:");
		foreach (var item in onlyInArray2)
		{
			Console.WriteLine(item);
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant