Class1.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:1k
- using System;
- using System.Collections.Specialized;
- using System.IO;
- using System.Reflection;
- namespace Wrox.ProCSharp.Assemblies.Sharing
- {
- public class SharedDemo
- {
- private StringCollection quotes;
- private Random random;
- public SharedDemo(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];
- }
- public string GetAssemblyFullName()
- {
- Assembly assembly = Assembly.GetExecutingAssembly();
- return assembly.FullName;
- }
- }
- }