C# StreamWriter Write(String, Object)
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,
Object arg0
)
Parameters
StreamWriter.Write(String, Object)
has the following parameters.
format
- A composite format string (see Remarks).arg0
- The object to format and write.
Returns
StreamWriter.Write(String, Object)
method returns
Example
Writes a formatted string to the text string or stream.
/*from w w w.jav a 2s . co m*/
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);
}
}
}