class1.cs

来自「Professional C# 2nd Edition」· CS 代码 · 共 31 行

CS
31
字号
using System;
using System.Collections.Specialized;
using System.IO;
namespace Wrox.ProCSharp.Assemblies.Sharing
{
	public class SimpleShared
	{
		private StringCollection quotes;
		private Random random;
		public SimpleShared(string filename)
		{
			quotes = new StringCollection();
			Stream stream = File.OpenRead(filename);
			StreamReader streamReader = new StreamReader(stream);
			string quote;
			while ((quote = streamReader.ReadLine()) != null)
			{
				quotes.Add(quote);
			}
			streamReader.Close();
			stream.Close();
			random = new Random();
		}
		public string GetQuoteOfTheDay()
		{
			int index = random.Next(1, quotes.Count);
			return quotes[index];
		}
	}
}

⌨️ 快捷键说明

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