C# StringWriter StringWriter(StringBuilder, IFormatProvider)

Description

StringWriter StringWriter(StringBuilder, IFormatProvider) Initializes a new instance of the StringWriter class that writes to the specified StringBuilder and has the specified format provider.

Syntax

StringWriter.StringWriter(StringBuilder, IFormatProvider) has the following syntax.


public StringWriter(
  StringBuilder sb,
  IFormatProvider formatProvider
)

Parameters

StringWriter.StringWriter(StringBuilder, IFormatProvider) has the following parameters.

  • sb - The StringBuilder to write to.
  • formatProvider - An IFormatProvider object that controls formatting.

Example


using System;/*from ww  w  .  j a v a  2  s  .c  om*/
using System.Globalization;
using System.IO;

class StrWriter
{
    static void Main()
    {
        
        
        StringWriter strWriter = new StringWriter(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