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)

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)

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

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)

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)

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)

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

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)

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)

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)

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[])

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

WriteLine(Char)

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

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()

Writes a line terminator string to the output stream.

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)

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.

C#
public override void WriteLine(string format, object arg0, object arg1);

Parameters

format
String

A string containing zero or more format items.

arg0
Object

An object to format.

arg1
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.

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(char[] buffer, int index, int count);

Parameters

buffer
Char[]

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

index
Int32

The location in the character array where writing begins.

count
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.

C#
private char[] testChars = {'h', 'e', 'l', 'l', 'o',
    HtmlTextWriter.SpaceChar ,'w', 'o', 'r', 'l', 'd'};

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.

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(string format, params object[] arg);

Parameters

format
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.

C#
// 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.

C#
private object[] curPriceTime = {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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(string format, object arg0);

Parameters

format
String

A string containing zero or more format items.

arg0
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.

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
[System.CLSCompliant(false)]
public override void WriteLine(uint value);

Parameters

value
UInt32

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

Attributes

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WriteLine(String)

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

C#
public override void WriteLine(string s);

Parameters

s
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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(float value);

Parameters

value
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>

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(int value);

Parameters

value
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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(long value);

Parameters

value
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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(double value);

Parameters

value
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>

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WriteLine(Char[])

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

C#
public override void WriteLine(char[] buffer);

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.

C#
private char[] testChars = {'h', 'e', 'l', 'l', 'o',
    HtmlTextWriter.SpaceChar ,'w', 'o', 'r', 'l', 'd'};

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

C#
// 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WriteLine(Char)

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

C#
public override void WriteLine(char value);

Parameters

value
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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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.

C#
public override void WriteLine(bool value);

Parameters

value
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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WriteLine()

Writes a line terminator string to the output stream.

C#
public override void WriteLine();

Examples

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

C#
// Control the encoding of attributes. 
// Simple known values do not need encoding.
writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Encoding, \"Required\"", true);
writer.AddAttribute("myattribute", "No "encoding " 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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WriteLine(Object)

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

C#
public override void WriteLine(object value);

Parameters

value
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.

C#
// 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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1