Share via


BerConverter.Encode(String, Object[]) 方法

定義

Encode(String, Object[]) 方法會使用 BER 對結構資料進行編碼,以擷取資料的二進位表示。

public:
 static cli::array <System::Byte> ^ Encode(System::String ^ format, ... cli::array <System::Object ^> ^ value);
public static byte[] Encode (string format, params object[] value);
static member Encode : string * obj[] -> byte[]
Public Shared Function Encode (format As String, ParamArray value As Object()) As Byte()

參數

format
String

格式字串。

value
Object[]

已格式化之資料的陣列。

傳回

Byte[]

BER 編碼之資料的陣列。

備註

以下是有效的格式字元。

編碼規則:

程式碼 對應的自變數
'{' '}' '[' ']' 'n' 沒有對應的自變數
't' 'i' 'e' int
'a' 八進位字串
'b' bool
's' 字串
'o' 'X' byte[]
'v' string[]
'V' byte[][]

注意

'v' 和 'V' 在需要雙精度浮 {} 點數時特別。 例如,使用 {{v}} 和 {{V}}。

例外狀況

例外狀況 條件
ArgumentNullException format 為 null 參考 (在 Visual Basic 中為 Nothing)。
ArgumentException 下列任一狀況都會發生此例外狀況:

- 格式字串沒有足夠的自變數。
- 格式字串自變數不正確。
- 格式字串包含未定義的字元。
BerConversionException 處理傳回值時發生錯誤。

適用於