Files and common dialog boxes

 

1.     C# classes can define a static constructor that is invoked exactly once for a class, typically just before the first reference to a member of that class. The Environment class contains members that reference the operating system environment of the user.

2.     The this keyword is used to invoke a local constructor from another AlbumManager constructor. This ensures that the logic in the default constructor code is executed prior to the current constructor code.

3.     The Environment class represents the current user’s operating system environment, providing the ability to retrieve and specify environment information. This class is sealed and the members defined by this class are static. The Environment class is part of the System namespace.

Common File Dialog boxes

1.     Supporting the ability to save and open files is a common task in many applications. The Windows Forms namespace includes a set of common dialog boxes to support these types of activities.

2.     Creating simple properties for your public fields is usually a good idea, and this discussion applies to private fields as well.

3.     Using TODO comments is a good way to make sure we come back to this work eventually.

Stream classes

1.     The abstract Stream class in the System.IO namespace provides a generic view of a sequence of bytes, and is the key to managing bytes in .NET from all manner of sources.

2.     The MemoryStream class manages bytes in memory, the FileStream class manages bytes in a file, and the BufferedStream class provides buffered access to the bytes in a stream.

3.     For reading and writing text, .NET provides the TextReader and TextWriter classes. These abstract classes encapsulate the notion of reading characters, rather than bytes, and are useful for managing textual data.

4.     The TextReader class represents a reader for a sequence of characters, and is part of the System.IO namespace. This class inherits from the System.MarshalByRefObject class. The StreamReader class for reading characters from a stream derives from this class.

5.     TextReader class:

 Close : Releases any system resources associated with the reader and closes it

 Peek: Returns the next character without actually reading it from the input stream

Read: Retrieves one or more characters from the input stream.

ReadLine: Retrieves a line of characters from the input stream as a string

 ReadToEnd: Retrieves all characters from the Current position to the end of the reader as a string.

6.     It is often a good idea to make use of a class before you actually implement    This may sound counterintuitive, but the idea is to write a test program or application that uses your class to verify that the methods make sense and accomplish the desired tasks.

posted on 2009-11-05 16:59  韩连生  阅读(260)  评论(0)    收藏  举报

导航