HtmlTextWriter.WriteLine HtmlTextWriter.WriteLine HtmlTextWriter.WriteLine HtmlTextWriter.WriteLine Method

Definition

Writes data to an HtmlTextWriter output stream, as specified by the overloaded parameters, followed by a line terminator string. All versions of this method write any pending tab spacing to the output stream.

Overloads

WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object)

Writes any pending tab spacing and a formatted string that contains the text representation of two objects, followed by a line terminator string, to the output stream.

WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32)

Writes any pending tab spacing and a subarray of Unicode characters, followed by a line terminator string, to the output stream.

WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[])

Writes any pending tab spacing and a formatted string that contains the text representation of an object array, followed by a line terminator string, to the output stream.

WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object)

Writes any pending tab spacing and a formatted string containing the text representation of an object, followed by a line terminator string, to the output stream.

WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32)

Writes any pending tab spacing and the text representation of a 4-byte unsigned integer, followed by a line terminator string, to the output stream.

WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)

Writes any pending tab spacing and a text string, followed by a line terminator string, to the output stream.

WriteLine(Single) WriteLine(Single) WriteLine(Single) WriteLine(Single)

Writes any pending tab spacing and the text representation of a single-precision floating-point number, followed by a line terminator string, to the output stream.

WriteLine(Int32) WriteLine(Int32) WriteLine(Int32) WriteLine(Int32)

Writes any pending tab spacing and the text representation of a 32-byte signed integer, followed by a line terminator string, to the output stream.

WriteLine(Int64) WriteLine(Int64) WriteLine(Int64) WriteLine(Int64)

Writes any pending tab spacing and the text representation of a 64-byte signed integer, followed by a line terminator string, to the output stream.

WriteLine(Double) WriteLine(Double) WriteLine(Double) WriteLine(Double)

Writes any pending tab spacing and the text representation of a double-precision floating-point number, followed by a line terminator string, to the output stream.

WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[])

Writes any pending tab spacing and an array of Unicode characters, followed by a line terminator string, to the output stream.

WriteLine(Char) WriteLine(Char) WriteLine(Char) WriteLine(Char)

Writes any pending tab spacing and a Unicode character, followed by a line terminator string, to the output stream.

WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean)

Writes any pending tab spacing and the text representation of a Boolean value, followed by a line terminator string, to the output stream.

WriteLine() WriteLine() WriteLine() WriteLine()

Writes a line terminator string to the output stream.

WriteLine(Object) WriteLine(Object) WriteLine(Object) WriteLine(Object)

Writes any pending tab spacing and the text representation of an object, followed by a line terminator string, to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object)

Writes any pending tab spacing and a formatted string that contains the text representation of two objects, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::String ^ format, System::Object ^ arg0, System::Object ^ arg1);
public override void WriteLine (string format, object arg0, object arg1);
override this.WriteLine : string * obj * obj -> unit
Public Overrides Sub WriteLine (format As String, arg0 As Object, arg1 As Object)

Parameters

format
String String String String

A string containing zero or more format items.

arg0
Object Object Object Object

An object to format.

arg1
Object Object Object Object

An object to format.

Examples

The following code example demonstrates how to use the WriteLine method to render a formatted string and the values of the CurrentCulture property and the Today property.

// Use the WriteLine(string,object,object) method to
// render a formatted string and two objects 
// in the string.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine("The current cultural settings are {0}. Today's date is {1}.",
    CultureInfo.CurrentCulture, DateTime.Today);
writer.RenderEndTag();
' Use the WriteLine(string,object,object) method to
' render a formatted string and two objects 
' in the string.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine("The current cultural settings are {0}. Today's date is {1}.", _
    CultureInfo.CurrentCulture, DateTime.Today)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine method uses the same semantics as the Format(String, Object, Object) method. The WriteLine base method is used to write the value parameter.

See also

WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32)

Writes any pending tab spacing and a subarray of Unicode characters, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(cli::array <char> ^ buffer, int index, int count);
public override void WriteLine (char[] buffer, int index, int count);
override this.WriteLine : char[] * int * int -> unit
Public Overrides Sub WriteLine (buffer As Char(), index As Integer, count As Integer)

Parameters

buffer
Char[]

The character array from which to write text to the output stream.

index
Int32 Int32 Int32 Int32

The location in the character array where writing begins.

count
Int32 Int32 Int32 Int32

The number of characters in the array to write to the output stream.

Examples

This section contains two code examples. The first one demonstrates how to create a character array. The second one demonstrates how to use the array.

These code examples generate the following markup:

<label>

hello

</label>

The following code example demonstrates how to create an array of characters that spell out hello world. Included in the array is the SpaceChar field, which creates a space between the two words.

private char[] testChars = {'h', 'e', 'l', 'l', 'o',
    HtmlTextWriter.SpaceChar ,'w', 'o', 'r', 'l', 'd'};
Private testChars() As Char = _
    {"h"c, "e"c, "l"c, "l"c, "o"c, _
    HtmlTextWriter.SpaceChar, "w"c, "o"c, "r"c, "l"c, "d"c}

The following code example uses the index and count parameters of the WriteLine method to render the first five characters of the array created in the preceding code example.

// Render a subarray of a character array
// as the contents of a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine(testChars, 0, 5);
writer.RenderEndTag();
' Render a subarray of a character array
' as the contents of a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine(testChars, 0, 5)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[])

Writes any pending tab spacing and a formatted string that contains the text representation of an object array, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::String ^ format, ... cli::array <System::Object ^> ^ arg);
public override void WriteLine (string format, params object[] arg);
override this.WriteLine : string * obj[] -> unit
Public Overrides Sub WriteLine (format As String, ParamArray arg As Object())

Parameters

format
String String String String

A string containing zero or more format items.

arg
Object[]

An object array to format.

Examples

This section contains two code examples. The first one demonstrates how to render a string and an array to the output stream. The second one shows how to declare the array.

The following code example demonstrates how to use the WriteLine method to render a formatted string and the contents of an object array to the output stream.

// Render a formatted string and the
// text representation of an object array,
// myObjectArray, as the contents of
// a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine("The trade value at {1} is ${0}.", curPriceTime);
writer.RenderEndTag();
' Render a formatted string and the
' text representation of an object array,
' myObjectArray, as the contents of
' a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine("The trade value at {1} is ${0}.", curPriceTime)
writer.RenderEndTag()

The following code example shows how to declare the object array that was rendered in the preceding code example.

private object[] curPriceTime = {4.25, DateTime.Now};
Private curPriceTime() As Object = {4.25, DateTime.Now}

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine method uses the same semantics as the Format(String, Object[]) method. The WriteLine base method is used to write the value method.

See also

WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object)

Writes any pending tab spacing and a formatted string containing the text representation of an object, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::String ^ format, System::Object ^ arg0);
public override void WriteLine (string format, object arg0);
override this.WriteLine : string * obj -> unit
Public Overrides Sub WriteLine (format As String, arg0 As Object)

Parameters

format
String String String String

A string containing zero or more format items.

arg0
Object Object Object Object

An object to format.

Examples

The following code example shows how to use the WriteLine method to render a formatted string with the value of the CurrentCulture property.

// Use the WriteLine(string, object) method to
// render a formatted string and an object in it.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine("The current cultural settings are {0}",
    CultureInfo.CurrentCulture);
writer.RenderEndTag();
' Use the WriteLine(string, object) method to
' render a formatted string and an object in it.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine("The current cultural settings are {0}.", _
    CultureInfo.CurrentCulture)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine method uses the same semantics as the Format(String, Object) method. The WriteLine base method is used to write the value parameter.

See also

WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32)

Important

This API is not CLS-compliant.

CLS-compliant alternative
System.Web.UI.HtmlTextWriter.WriteLine(Int64)

Writes any pending tab spacing and the text representation of a 4-byte unsigned integer, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::UInt32 value);
[System.CLSCompliant(false)]
public override void WriteLine (uint value);
override this.WriteLine : uint32 -> unit
Public Overrides Sub WriteLine (value As UInteger)

Parameters

value
UInt32 UInt32 UInt32 UInt32

The 4-byte unsigned integer to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)

Writes any pending tab spacing and a text string, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::String ^ s);
public override void WriteLine (string s);
override this.WriteLine : string -> unit
Public Overrides Sub WriteLine (s As String)

Parameters

s
String String String String

The string to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Single) WriteLine(Single) WriteLine(Single) WriteLine(Single)

Writes any pending tab spacing and the text representation of a single-precision floating-point number, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(float value);
public override void WriteLine (float value);
override this.WriteLine : single -> unit
Public Overrides Sub WriteLine (value As Single)

Parameters

value
Single Single Single Single

The single-precision floating point number to write to the output stream.

Examples

The following code example shows how to use the WriteLine method to render the value of the Single.Epsilon field, which is the smallest possible value of the Single structure.

This code example generates the following markup:

<b>

1.401298E-45

</b>

// Use the WriteLine(Single) method to render the
// Epsilon field of the Single structure.
writer.RenderBeginTag(HtmlTextWriterTag.B);
writer.WriteLine(Single.Epsilon);
writer.RenderEndTag();
' Use the WriteLine(Single) method to render the
' Epsilon field of the Single structure. 
writer.RenderBeginTag(HtmlTextWriterTag.B)
writer.WriteLine(Single.Epsilon)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Int32) WriteLine(Int32) WriteLine(Int32) WriteLine(Int32)

Writes any pending tab spacing and the text representation of a 32-byte signed integer, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(int value);
public override void WriteLine (int value);
override this.WriteLine : int -> unit
Public Overrides Sub WriteLine (value As Integer)

Parameters

value
Int32 Int32 Int32 Int32

The 32-byte signed integer to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Int64) WriteLine(Int64) WriteLine(Int64) WriteLine(Int64)

Writes any pending tab spacing and the text representation of a 64-byte signed integer, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(long value);
public override void WriteLine (long value);
override this.WriteLine : int64 -> unit
Public Overrides Sub WriteLine (value As Long)

Parameters

value
Int64 Int64 Int64 Int64

The 64-byte signed integer to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Double) WriteLine(Double) WriteLine(Double) WriteLine(Double)

Writes any pending tab spacing and the text representation of a double-precision floating-point number, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(double value);
public override void WriteLine (double value);
override this.WriteLine : double -> unit
Public Overrides Sub WriteLine (value As Double)

Parameters

value
Double Double Double Double

The double-precision floating-point number to write to the output stream.

Examples

The following code example shows how to use the WriteLine method to render the value of the Double.MaxValue field.

This code example generates the following markup:

<label>

1.79769313486232E+308

</label>

// Use the WriteLine(Double) method to render
// the MaxValue field of the Double structure. 
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine(Double.MaxValue);
writer.RenderEndTag();
' Use the WriteLine(Double) method to render
' the MaxValue field of the Double structure. 
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine(Double.MaxValue)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[])

Writes any pending tab spacing and an array of Unicode characters, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(cli::array <char> ^ buffer);
public override void WriteLine (char[] buffer);
override this.WriteLine : char[] -> unit
Public Overrides Sub WriteLine (buffer As Char())

Parameters

buffer
Char[]

The character array to write to the output stream.

Examples

This section provides two code examples. The first one demonstrates how to create an array. The second one demonstrates how to use that array.

These code examples generate the following markup:

<label>

hello world

</label>

The following code example shows how to create an array of characters that spell out hello world. Included in the array is the SpaceChar field, which creates a space between the two words.

private char[] testChars = {'h', 'e', 'l', 'l', 'o',
    HtmlTextWriter.SpaceChar ,'w', 'o', 'r', 'l', 'd'};
Private testChars() As Char = _
    {"h"c, "e"c, "l"c, "l"c, "o"c, _
    HtmlTextWriter.SpaceChar, "w"c, "o"c, "r"c, "l"c, "d"c}

The following code example renders the hello world character array that was created in the preceding example by using the WriteLine method.

// Render a character array as the contents of 
// a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteLine(testChars);
writer.RenderEndTag();
' Render a character array as the 
' contents of a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine(testChars)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Char) WriteLine(Char) WriteLine(Char) WriteLine(Char)

Writes any pending tab spacing and a Unicode character, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(char value);
public override void WriteLine (char value);
override this.WriteLine : char -> unit
Public Overrides Sub WriteLine (value As Char)

Parameters

value
Char Char Char Char

The character to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean)

Writes any pending tab spacing and the text representation of a Boolean value, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(bool value);
public override void WriteLine (bool value);
override this.WriteLine : bool -> unit
Public Overrides Sub WriteLine (value As Boolean)

Parameters

value
Boolean Boolean Boolean Boolean

The Boolean to write to the output stream.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

WriteLine() WriteLine() WriteLine() WriteLine()

Writes a line terminator string to the output stream.

public:
 override void WriteLine();
public override void WriteLine ();
override this.WriteLine : unit -> unit
Public Overrides Sub WriteLine ()

Examples

The following code example demonstrates how to use the WriteLine method to insert a line after an <img> element is rendered.

// Control the encoding of attributes.
// Simple known values do not need encoding.
writer->AddAttribute( HtmlTextWriterAttribute::Alt, "Encoding, \"Required\"", true );
writer->AddAttribute( "myattribute", "No &quot;encoding &quot; required", false );
writer->RenderBeginTag( HtmlTextWriterTag::Img );
writer->RenderEndTag();
writer->WriteLine();
// Control the encoding of attributes. 
// Simple known values do not need encoding.
writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Encoding, \"Required\"", true);
writer.AddAttribute("myattribute", "No &quot;encoding &quot; required", false);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
writer.WriteLine();
' Control the encoding of attributes.
' Simple known values do not need encoding.
writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Encoding, ""Required""", True)
writer.AddAttribute("myattribute", "No &quot;encoding &quot; required", False)
writer.RenderBeginTag(HtmlTextWriterTag.Img)
writer.RenderEndTag()
writer.WriteLine()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). For more information, see WriteLine.

See also

WriteLine(Object) WriteLine(Object) WriteLine(Object) WriteLine(Object)

Writes any pending tab spacing and the text representation of an object, followed by a line terminator string, to the output stream.

public:
 override void WriteLine(System::Object ^ value);
public override void WriteLine (object value);
override this.WriteLine : obj -> unit
Public Overrides Sub WriteLine (value As Object)

Parameters

value
Object Object Object Object

The object to write to the output stream.

Examples

The following code example shows how to use the WriteLine method to render the value of the CultureInfo.CurrentCulture property to a control.

// Use the WriteLine method to render an arbitrary
// object, in this case a CutltureInfo object.
writer.RenderBeginTag(HtmlTextWriterTag.B);
writer.WriteLine(CultureInfo.CurrentCulture);
writer.RenderEndTag();
' Use the WriteLine method to render an arbitrary
' object, in this case a CutltureInfo object.
writer.RenderBeginTag(HtmlTextWriterTag.B)
writer.WriteLine(CultureInfo.CurrentCulture)
writer.RenderEndTag()

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n"). The WriteLine base method is used to write the value parameter.

See also

Applies to