本文整理汇总了VB.NET中System.Base64FormattingOptions枚举的典型用法代码示例。如果您正苦于以下问题:VB.NET Base64FormattingOptions枚举的具体用法?VB.NET Base64FormattingOptions怎么用?VB.NET Base64FormattingOptions使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了Base64FormattingOptions枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
Module Example
Public Sub Main()
' Define a byte array.
Dim bytes(99) As Byte
Dim originalTotal As Integer = 0
For ctr As Integer = 0 To bytes.GetUpperBound(0)
bytes(ctr) = CByte(ctr + 1)
originalTotal += bytes(ctr)
Next
' Display summary information about the array.
Console.WriteLine("The original byte array:")
Console.WriteLine(" Total elements: {0}", bytes.Length)
Console.WriteLine(" Length of String Representation: {0}",
BitConverter.ToString(bytes).Length)
Console.WriteLine(" Sum of elements: {0:N0}", originalTotal)
Console.WriteLine()
' Convert the array to a base 64 string.
Dim s As String = Convert.ToBase64String(bytes,
Base64FormattingOptions.InsertLineBreaks)
Console.WriteLine("The base 64 string:{1} {0}{1}",
s, vbCrLf)
' Restore the byte array.
Dim newBytes() As Byte = Convert.FromBase64String(s)
Dim newTotal As Integer = 0
For Each newByte In newBytes
newTotal += newByte
Next
' Display summary information about the restored array.
Console.WriteLine(" Total elements: {0}", newBytes.Length)
Console.WriteLine(" Length of String Representation: {0}",
BitConverter.ToString(newBytes).Length)
Console.WriteLine(" Sum of elements: {0:N0}", newTotal)
End Sub
End Module
输出:
The original byte array: Total elements: 100 Length of String Representation: 299 Sum of elements: 5,050 The base 64 string: AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5 Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaW1xdXl9gYWJjZA== Total elements: 100 Length of String Representation: 299 Sum of elements: 5,050