utility.cs

来自「移动设备的 LINQ 编程介绍 .NET Compact Framework 版」· CS 代码 · 共 34 行

CS
34
字号
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Demo1___LinqToObjects
{
	static class Utility
	{
		public static string[] ReadAllLines(string path)
		{
			string[] lines = null;

			if (!File.Exists(path))
				throw new FileNotFoundException(path);

			using (StreamReader sr = File.OpenText(path))
			{
				List<string> lineList = new List<string>();
				string line;
				while ((line = sr.ReadLine()) != null)
				{
					lineList.Add(line);
				}
				lines = lineList.ToArray();
			}

			return lines;
		}
	}
}

⌨️ 快捷键说明

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