C# StreamWriter Write(String, Object[]) Array

Description

StreamWriter Write(String, Object[]) Writes a formatted string to the text string or stream, using the same semantics as the String.Format(String, Object[]) method.

Syntax

StreamWriter.Write(String, Object[]) has the following syntax.


public virtual void Write(
  string format,
  params Object[] arg
)

Parameters

StreamWriter.Write(String, Object[]) has the following parameters.

  • format - A composite format string (see Remarks).
  • arg - An object array that contains zero or more objects to format and write.

Returns

StreamWriter.Write(String, Object[]) method returns

Example


//  w w w  . j  a  v  a  2s. com
using System;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string fileName = "test.txt";

        using (StreamWriter writer = new StreamWriter(fileName))
        {
            writer.Write("{0} java2s.com",123);
        }
    }
}




















Home »
  C# Tutorial »
    System.IO »




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