HtmlTextWriter.Write メソッド

定義

保留中のタブ空白文字と共に、指定したデータ型を出力ストリームに書き込みます。

オーバーロード

Write(Boolean)

保留中のタブ空白文字と共に、ブール値のテキスト形式を出力ストリームに書き込みます。

Write(Char)

保留中のタブ空白文字と共に、Unicode 文字のテキスト形式を出力ストリームに書き込みます。

Write(Char[])

保留中のタブ空白文字と共に、Unicode 文字の配列のテキスト形式を出力ストリームに書き込みます。

Write(Double)

保留中のタブ空白文字と共に、倍精度浮動小数点数のテキスト形式を出力ストリームに書き込みます。

Write(Int32)

保留中のタブ空白文字と共に、32 バイトの符号付き整数のテキスト形式を出力ストリームに書き込みます。

Write(Int64)

保留中のタブ空白文字と共に、64 バイトの符号付き整数のテキスト形式を出力ストリームに書き込みます。

Write(Object)

保留中のタブ空白文字と共に、オブジェクトのテキスト形式を出力ストリームに書き込みます。

Write(Single)

保留中のタブ空白文字と共に、単精度浮動小数点数のテキスト形式を出力ストリームに書き込みます。

Write(String)

保留中のタブ空白文字と共に、指定した文字列を出力ストリームに書き込みます。

Write(String, Object)

保留中のタブ空白文字と共に、Format(String, Object) メソッドと同じセマンティクスを使用して、タブ文字列と書式設定された文字列を出力ストリームに書き込みます。

Write(String, Object[])

保留中のタブ空白文字と共に、オブジェクト配列のテキスト形式を格納する書式設定された文字列を出力ストリームに書き込みます。 このメソッドは Format(String, Object[]) メソッドと同じセマンティクスを使用します。

Write(Char[], Int32, Int32)

保留中のタブ空白文字と共に、Unicode 文字の部分配列のテキスト形式を出力ストリームに書き込みます。

Write(String, Object, Object)

保留中のタブ空白文字と共に、2 つのオブジェクトのテキスト形式を格納する書式設定された文字列を出力ストリームに書き込みます。 このメソッドは Format(String, Object, Object) メソッドと同じセマンティクスを使用します。

Write(Boolean)

保留中のタブ空白文字と共に、ブール値のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Boolean

出力ストリームに書き込む Boolean

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Char)

保留中のタブ空白文字と共に、Unicode 文字のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Char

出力ストリームに書き込む Unicode 文字。

次のコード例では、 メソッドを使用して、 定数を Write 使用して要素の開始タグを <img> 終了する方法を TagRightChar 示します。

このコード例では、次のマークアップをレンダリングします。

<img alt="A custom image">

</img>

// Create a manually rendered <img> element
// that contains an alt attribute.
writer.WriteBeginTag("img");
writer.WriteAttribute("alt", "A custom image.");
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteEndTag("img");
' Create a manually rendered <img> element
' that contains an alt attribute.
writer.WriteBeginTag("img")
writer.WriteAttribute("alt", "A custom image.")
writer.Write(HtmlTextWriter.TagRightChar)
writer.WriteEndTag("img")

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Char[])

保留中のタブ空白文字と共に、Unicode 文字の配列のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

buffer
Char[]

出力ストリームに書き込む Unicode 文字の配列。

このセクションでは、2 つのコード例を示します。 最初の例では、文字の配列を作成する方法を示します。 2 つ目は、 配列の使用方法を示しています。

これらのコード例では、次のマークアップが生成されます。

<label>

hello world

</label>

次のコード例では、 を指定 hello worldする文字の配列を作成する方法を示します。 配列に含まれるフィールド SpaceChar は、2 つの単語の間にスペースを作成します。

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}

次のコード例では、 メソッドを Write 使用して、このコード例を含むコントロールがページに含まれている場合に、前のコード例で作成した文字配列をページにレンダリング hello world する方法を示します。

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Double)

保留中のタブ空白文字と共に、倍精度浮動小数点数のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Double

出力ストリームに書き込む倍精度浮動小数点数。

次のコード例は、 メソッドを使用 Write して フィールドの値をレンダリングする方法を Double.MaxValue 示しています。

このコード例では、次のマークアップを生成します。

<label>

1.79769313486232E+308

</label>

// Use the Write(Double) method to render
// the MaxValue field of the Double structure. 
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write(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()

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Int32)

保留中のタブ空白文字と共に、32 バイトの符号付き整数のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Int32

出力ストリームに書き込む 32 バイト符号付き整数。

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Int64)

保留中のタブ空白文字と共に、64 バイトの符号付き整数のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Int64

出力ストリームに書き込む 64 バイト符号付き整数。

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Object)

保留中のタブ空白文字と共に、オブジェクトのテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Object

出力ストリームに書き込むオブジェクト。

次のコード例は、 Write メソッドを使用して プロパティの値をレンダリングする方法を CultureInfo.CurrentCulture 示しています。

このコード例では、次のマークアップを生成します。

This is a rendered CultureInfo object.

<bold>

プロパティの CurrentCulture 値:

</bold>

// Use the Write method to render an arbitrary
// object, in this case a CultureInfo object. 
writer.Write("This is a rendered CultureInfo Object.");
writer.RenderBeginTag(HtmlTextWriterTag.B);
writer.Write(CultureInfo.CurrentCulture);
writer.RenderEndTag();
' Use the Write method to render an arbitrary
' object, in this case a CultureInfo object.
writer.Write("This is a rendered CultureInfo Object.")
writer.RenderBeginTag(HtmlTextWriterTag.B)
writer.Write(CultureInfo.CurrentCulture)
writer.RenderEndTag()

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Single)

保留中のタブ空白文字と共に、単精度浮動小数点数のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

value
Single

出力ストリームに書き込む単精度浮動小数点数。

次のコード例では、 メソッドを Write 使用して、構造体の Single.Epsilon 可能な限り小さい値である フィールドの値をレンダリングする方法を Single 示します。

このコード例では、次のマークアップを生成します。

<b>

1.401298E-45

</b>

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(String)

保留中のタブ空白文字と共に、指定した文字列を出力ストリームに書き込みます。

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

パラメーター

s
String

出力ストリームに書き込む文字列。

次のコード例では、 メソッドを使用して、カスタム マークアップ要素の Write 開始タグと終了タグの間に文字列をレンダリングする方法を示します。

このコード例では、次のマークアップを生成します。

<MyTag>

Contents of MyTag

</MyTag>

// Create a non-standard tag.
writer->RenderBeginTag( "MyTag" );
writer->Write( "Contents of MyTag" );
writer->RenderEndTag();
writer->WriteLine();
// Create a non-standard tag.
writer.RenderBeginTag("MyTag");
writer.Write("Contents of MyTag");
writer.RenderEndTag();
writer.WriteLine();
' Create a non-standard tag.
writer.RenderBeginTag("MyTag")
writer.Write("Contents of MyTag")
writer.RenderEndTag()
writer.WriteLine()

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(String, Object)

保留中のタブ空白文字と共に、Format(String, Object) メソッドと同じセマンティクスを使用して、タブ文字列と書式設定された文字列を出力ストリームに書き込みます。

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

パラメーター

format
String

0 個以上の書式項目を格納している文字列。

arg0
Object

書式指定するオブジェクト。

次のコード例は、 メソッドを使用して、 プロパティの Write 値を使用して書式設定された文字列をレンダリングする方法を CurrentCulture 示しています。

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(String, Object[])

保留中のタブ空白文字と共に、オブジェクト配列のテキスト形式を格納する書式設定された文字列を出力ストリームに書き込みます。 このメソッドは Format(String, Object[]) メソッドと同じセマンティクスを使用します。

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

パラメーター

format
String

0 個以上の書式項目を格納している文字列。

arg
Object[]

書式設定するオブジェクト配列。

このセクションには、2 つのコード例が含まれています。 1 つ目は、書式設定された文字列と配列の内容をレンダリングする方法を示しています。 2 つ目は、配列を宣言する方法を示しています。

次のコード例は、 メソッドを Write 使用して、書式設定された文字列と、 という名前 curPriceTimeのオブジェクト配列の内容をレンダリングする方法を示しています。 メソッド呼び出しは、最初のメンバーをレンダリングする前に、配列の 2 番目のメンバーをレンダリングします。

// 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.Write("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.Write("The trade value at {1} is ${0}.", curPriceTime)
writer.RenderEndTag()

次のコード例では、オブジェクト配列の宣言を curPriceTime 示します。

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(Char[], Int32, Int32)

保留中のタブ空白文字と共に、Unicode 文字の部分配列のテキスト形式を出力ストリームに書き込みます。

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

パラメーター

buffer
Char[]

出力ストリームへのテキストの書き込み元となる文字配列。

index
Int32

書き込みの開始位置を示す配列内のインデックス位置。

count
Int32

出力ストリームに書き込む文字数。

このセクションでは、2 つのコード例を示します。 1 つ目は、文字配列を作成する方法を示しています。 2 つ目は、 配列の使用方法を示しています。

これらのコード例では、次のマークアップが生成されます。

<label>

hello

</label>

次のコード例は、 を入力 hello worldする文字の配列を作成する方法を示しています。 配列に含まれるフィールド SpaceChar は、2 つの単語の間にスペースを作成します。

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}

コード例の次の部分では、 index メソッドの パラメーターと count パラメーターを Write 使用して、前の例で作成した配列の最初の 5 文字をレンダリングします。

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象

Write(String, Object, Object)

保留中のタブ空白文字と共に、2 つのオブジェクトのテキスト形式を格納する書式設定された文字列を出力ストリームに書き込みます。 このメソッドは Format(String, Object, Object) メソッドと同じセマンティクスを使用します。

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

パラメーター

format
String

0 個以上の書式項目を格納している文字列。

arg0
Object

書式指定するオブジェクト。

arg1
Object

書式指定するオブジェクト。

次のコード例は、 メソッドを使用Writeして、書式設定された文字列と および プロパティの値をレンダリングする方法をCurrentCultureToday示しています。

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

注釈

メソッドは Write 保留中のタブを生成し、基本メソッドを Write 呼び出します。

こちらもご覧ください

適用対象