C# StreamWriter Write(Object)

Description

StreamWriter Write(Object) Writes the text representation of an object to the text string or stream by calling the ToString method on that object.

Syntax

StreamWriter.Write(Object) has the following syntax.


public virtual void Write(
  Object value
)

Parameters

StreamWriter.Write(Object) has the following parameters.

  • value - The object to write.

Returns

StreamWriter.Write(Object) method returns

Example


using System;/*from w w  w.  jav  a 2s.co m*/
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((Object)123);
        }
    }
}




















Home »
  C# Tutorial »
    System.IO »




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