Message.BodyType 屬性

定義

取得或設定訊息本文包含的資料類型。Gets or sets the type of data that the message body contains.

public:
 property int BodyType { int get(); void set(int value); };
[System.Messaging.MessagingDescription("MsgBodyType")]
public int BodyType { get; set; }
[<System.Messaging.MessagingDescription("MsgBodyType")>]
member this.BodyType : int with get, set
Public Property BodyType As Integer

屬性值

Int32

訊息主體的真正型別,例如字串、日期、貨幣或數字。The message body's true type, such as a string, a date, a currency, or a number.

屬性

例外狀況

篩選訊息佇列以忽略 Body 屬性。The message queue is filtered to ignore the Body property.

範例

下列程式碼範例會顯示訊息的 BodyType 屬性值。The following code example displays the value of a message's BodyType property.

備註

訊息佇列會將本文內容辨識為物件或已序列化的資料流程。Message Queuing recognizes the body contents as an object or as a serialized stream. BodyType屬性工作表示訊息屬性內的物件類型 BodyThe BodyType property indicates the type of the object within the Body property of the message.

會在 XmlMessageFormatter 原生類型與訊息主體中的物件之間執行系結。The XmlMessageFormatter performs binding between native types and the object in a message body. 如果您使用 XmlMessageFormatter ,格式器會 BodyType 為您設定屬性。If you use the XmlMessageFormatter, the formatter sets the BodyType property for you.

其他格式子也可以提供系結功能,如下列 c # 程式碼所示。Other formatters can provide binding functionality also, as shown in the following C# code.

message.Formatter = new ActiveXMessageFormatter();  
object myObject message.Body;  
if (myObject is string) {  
}  
if (myObject is int) {  
}  
if (myObject is float) {  
}  

適用於

另請參閱