- 529 名前:デフォルトの名無しさん mailto:sage [2009/02/25(水) 10:04:22 ]
- >>497
こんなのはどうかね public abstract class ReaderWriter<T> : IDisposable { protected FileStream stream; protected BinaryWriter writer; protected BinaryReader reader; public abstract void Write(T item); public abstract T Read(); public virtual void Seek(long offset, SeekOrigin origin) { this.stream.Seek(offset, origin); } public void Dispose() { if (this.reader != null) this.reader.Close(); if (this.writer != null) this.writer.Close(); if (this.stream != null) this.stream.Close(); } } public class IntReaderWriter : ReaderWriter<int> { public IntReaderWriter(string fileName) { this.stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); this.reader = new BinaryReader(this.stream); this.writer = new BinaryWriter(this.stream); } public override void Write(int item) { this.writer.Write(item); } public override int Read() { return this.reader.ReadInt32(); } }
|

|