Chapter 10 – Working with Files, Streams, and Serialization
- What is the difference between using the
File
class and theFileInfo
class?The
File
class has static methods so it cannot be instantiated. It is best used for one-off tasks such as copying a file. TheFileInfo
class requires the instantiation of an object that represents a file. It is best used when you need to perform multiple operations on the same file. - What is the difference between the
ReadByte
method and theRead
method of a stream?The
ReadByte
method returns a single byte each time it is called and theRead
method fills a temporary array with bytes up to a specified length. It is generally best to useRead
to process blocks of bytes at once. - When would you use the
StringReader
, the ...
Get C# 6 and .NET Core 1.0: Modern Cross-Platform Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.