C# StringWriter StringWriter(IFormatProvider)

Description

StringWriter StringWriter(IFormatProvider) Initializes a new instance of the StringWriter class with the specified format control.

Syntax

StringWriter.StringWriter(IFormatProvider) has the following syntax.


public StringWriter(
  IFormatProvider formatProvider
)

Parameters

StringWriter.StringWriter(IFormatProvider) has the following parameters.

  • formatProvider - An IFormatProvider object that controls formatting.

Example

The following code example demonstrates how to construct a string in a specific culture.


/*  w ww  .  java  2s . c  o  m*/
using System;
using System.Globalization;
using System.IO;
using System.Text;

class StrWriter
{
    static void Main()
    {
        StringBuilder strBuilder = new StringBuilder("from java2s.com ");

        StringWriter strWriter = new StringWriter(strBuilder, new CultureInfo("ar-DZ"));

        strWriter.Write(DateTime.Now);

        Console.WriteLine(DateTime.Now.ToString(), strWriter.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter