【发布时间】:2010-10-23 14:47:40
【问题描述】:
大多数时候,当我们将文件流读入字节数组时,我们会编写如下代码:-
Dim inputStream As New System.IO.FileStream(filePath, IO.FileMode.Open)
Dim fileLength As Integer= CType(inputStream.Length, Integer)
Dim input(fileLength) As Byte
Using inputStream
inputStream.Read(input, 0, fileLength)
End Using
但是这里我们必须将 Length 转换为整数类型(上面代码的第 2 行),因为我们不能使用 long 数据类型(带有选项 strict)声明字节数组。这是一个好习惯吗?解决这个问题的方法是什么?
【问题讨论】:
标签: vb.net arrays initialization