collectionwrapper.cs
来自「集学生管理系统、学生选课系统、老师管理系统与一身 不错的」· CS 代码 · 共 51 行
CS
51 行
// CollectionWrapper.cs - Chapter 15 version.
// Copyright 2004 by Jacquie Barker and Grant Palmer - all rights reserved.
// An IMPLEMENTATION class.
using System;
using System.IO;
public abstract class CollectionWrapper {
private string pathToFile;
public bool InitializeObjects(string pathToFile, bool primary) {
this.pathToFile = pathToFile;
string line = null;
StreamReader srIn = null;
bool outcome = true;
try {
// Open the file.
srIn = new StreamReader(new FileStream(pathToFile, FileMode.Open));
line = srIn.ReadLine();
while (line != null) {
if (primary) {
ParseData(line);
}
else {
ParseData2(line);
}
line = srIn.ReadLine();
}
srIn.Close();
}
catch (FileNotFoundException f) {
Console.WriteLine(f);
outcome = false;
}
catch (IOException i) {
Console.WriteLine(i);
outcome = false;
}
return outcome;
}
public abstract void ParseData(string line);
public abstract void ParseData2(string line);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?