TextWriter.FormatProvider 属性


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

 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属性的值指定Write调用和WriteLine方法时使用的特定于区域性的格式设置。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. 当属性包含null时,当前线程的区域性用于格式设置。 FormatProviderWhen 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.