⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmcollection.cs

📁 移动设备的 LINQ 编程介绍 .NET Compact Framework 版 LINQ 的特性
💻 CS
字号:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;

namespace Demo1___LinqToObjects
{
	public partial class FrmCollection : Form
	{
		string appPath;

		public FrmCollection()
		{
			InitializeComponent();

			appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
		}

		private void menuItem1_Click(object sender, EventArgs e)
		{
			Cursor.Current = Cursors.WaitCursor;

			// Create the IEnumerable data sources.
			string[] names1 = Utility.ReadAllLines(appPath + @"\names1.txt");
			string[] names2 = Utility.ReadAllLines(appPath + @"\names2.txt");

			// Create the query. Note that method syntax must be used here.
			IEnumerable<string> differenceQuery =
			  names1.Except(names2);

			StringBuilder sb = new StringBuilder();
			sb.AppendLine("The following lines are in names1.txt but not names2.txt").AppendLine();
			foreach (string s in differenceQuery)
			{
				sb.AppendLine(s);
			}
			sb.AppendLine();

			// Find the names that occur in both files (based on
			// default string comparer).
			IEnumerable<string> intersectQuery =
				names1.Intersect(names2);

			sb.AppendLine("The following lines are both in names1.txt and names2.txt").AppendLine();
			foreach (string s in intersectQuery)
			{
				sb.AppendLine(s);
			}

			textBox1.AppendLine(sb.ToString());

			Cursor.Current = Cursors.Default;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -