Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StreamWriter.Write Method

Writes to the stream.

Overload List

Writes a character to the stream.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Overrides Public Sub Write(Char)
[C#] public override void Write(char);
[C++] public: void Write(__wchar_t);
[JScript] public override function Write(Char);

Writes a character array to the stream.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Overrides Public Sub Write(Char())
[C#] public override void Write(char[]);
[C++] public: void Write(__wchar_t __gc[]);
[JScript] public override function Write(Char[]);

Writes a string to the stream.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Overrides Public Sub Write(String)
[C#] public override void Write(string);
[C++] public: void Write(String*);
[JScript] public override function Write(String);

Writes a subarray of characters to the stream.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Overrides Public Sub Write(Char(), Integer, Integer)
[C#] public override void Write(char[], int, int);
[C++] public: void Write(__wchar_t __gc[], int, int);
[JScript] public override function Write(Char[], int, int);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Boolean)
[C#] public virtual void Write(bool);
[C++] public: virtual void Write(bool);
[JScript] public function Write(Boolean);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Decimal)
[C#] public virtual void Write(decimal);
[C++] public: virtual void Write(Decimal);
[JScript] public function Write(Decimal);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Double)
[C#] public virtual void Write(double);
[C++] public: virtual void Write(double);
[JScript] public function Write(double);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Integer)
[C#] public virtual void Write(int);
[C++] public: virtual void Write(int);
[JScript] public function Write(int);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Long)
[C#] public virtual void Write(long);
[C++] public: virtual void Write(__int64);
[JScript] public function Write(long);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Object)
[C#] public virtual void Write(object);
[C++] public: virtual void Write(Object*);
[JScript] public function Write(Object);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(Single)
[C#] public virtual void Write(float);
[C++] public: virtual void Write(float);
[JScript] public function Write(float);

Inherited from TextWriter. This method is not CLS-compliant.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(UInt32)
[C#] public virtual void Write(uint);
[C++] public: virtual void Write(unsigned int);
[JScript] public function Write(UInt32);

Inherited from TextWriter. This method is not CLS-compliant.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(UInt64)
[C#] public virtual void Write(ulong);
[C++] public: virtual void Write(unsigned __int64);
[JScript] public function Write(UInt64);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(String, Object)
[C#] public virtual void Write(string, object);
[C++] public: virtual void Write(String*, Object*);
[JScript] public function Write(String, Object);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(String, ParamArray Object())
[C#] public virtual void Write(string, params object[]);
[C++] public: virtual void Write(String*, Object[]);
[JScript] public function Write(String, Object[]);

Inherited from TextWriter.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub Write(String, Object, Object)
[C#] public virtual void Write(string, object, object);
[C++] public: virtual void Write(String*, Object*, Object*);
[JScript] public function Write(String, Object, Object);

Inherited from TextWriter.

[Visual Basic] Overloads Public Overridable Sub Write(String, Object, Object, Object)
[C#] public virtual void Write(string, object, object, object);
[C++] public: virtual void Write(String*, Object*, Object*, Object*);
[JScript] public function Write(String, Object, Object, Object);

Example

[Visual Basic, C#, C++] This example writes eight characters from a 13-element array to a file, beginning at the third element of the array.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of Write. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System
Imports System.IO

Public Class SWBuff

    Public Shared Sub Main()
        Dim sb As New FileStream("MyFile.txt", FileMode.OpenOrCreate)
        Dim b As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, _
           "h"c, "i"c, "j"c, "k"c, "l"c, "m"c}
        Dim sw As New StreamWriter(sb)
        sw.Write(b, 3, 8)
        sw.Close()
    End Sub
End Class

[C#] 
using System;
using System.IO;
 
public class SWBuff 
{
    public static void Main(String[] args)
    {
        FileStream sb = new FileStream("MyFile.txt", FileMode.OpenOrCreate);
        char[] b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
        StreamWriter sw = new StreamWriter(sb);
        sw.Write(b, 3, 8);
        sw.Close();
    }
}

[C++] 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

StreamWriter Class | StreamWriter Members | System.IO Namespace

Show:
© 2018 Microsoft