Message.BodyType 屬性

定義

取得或設定訊息本文包含的資料類型。

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

屬性值

訊息主體的真正型別,例如字串、日期、貨幣或數字。

屬性

例外狀況

篩選訊息佇列以忽略 Body 屬性。

範例

下列程式代碼範例會顯示訊息的 BodyType 屬性值。

備註

消息佇列會將本文內容辨識為物件或串行化數據流。 屬性 BodyType 會指出訊息之 屬性內的 Body 物件類型。

會在 XmlMessageFormatter 訊息本文中執行原生類型與 對象之間的系結。 如果您使用 XmlMessageFormatter,格式子會 BodyType 為您設定 屬性。

其他格式器也可以提供系結功能,如下列 C# 程式代碼所示。

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

適用於

另請參閱