TextWriter.FormatProvider 属性

定义

获取控制格式设置的对象。Gets an object that controls formatting.

public:
 virtual property IFormatProvider ^ FormatProvider { IFormatProvider ^ get(); };
public virtual IFormatProvider FormatProvider { get; }
member this.FormatProvider : IFormatProvider
Public Overridable ReadOnly Property FormatProvider As IFormatProvider

属性值

特定区域性的 IFormatProvider 对象,或者如果未指定任何其他区域性,则为当前区域性的格式设置。An IFormatProvider object for a specific culture, or the formatting of the current culture if no other culture is specified.

注解

FormatProvider 属性的值指定调用 WriteWriteLine 方法时使用的特定于区域性的格式设置。The value of the FormatProvider property specifies the culture-specific formatting that is used when you call the Write and WriteLine methods. 如果你不希望提供格式提供程序,则可以使用 TextWriter() 构造函数创建一个实例,该构造函数将 FormatProvider 属性设置为 nullIf you do not want to provide a format provider, you create an instance by using the TextWriter() constructor, which sets the FormatProvider property to null. FormatProvider 属性包含 null时,当前线程的区域性用于格式设置。When the FormatProvider property contains null, the culture of the current thread is used for formatting.

有关创建文件和将文本写入文件的示例,请参阅如何:将文本写入文件For an example of creating a file and writing text to a file, see How to: Write Text to a File. 有关从文件读取文本的示例,请参阅如何:从文件读取文本For an example of reading text from a file, see How to: Read Text from a File. 有关从二进制文件读取和写入二进制文件的示例,请参阅如何:读取和写入到新创建的数据文件For an example of reading from and writing to a binary file, see How to: Read and Write to a Newly Created Data File.

有关常见 i/o 任务的列表,请参阅常见 I/o 任务For a list of common I/O tasks, see Common I/O Tasks.

适用于

另请参阅