Converting JScript to VB.NET - Questions
I'm trying to convert some functions written in JScript to VB.NET (I'm porting a classic ASP page to ASP.NET) and having issues as I'm not very familiar with JScript. I'm having issues with converting even the function declaration properly in 开发者_JAVA百科VB.NET. In my converted code VS2008 is giving me an error saying "Array bounds can not be specified in type identifiers". I don't know how to modify my function declaration to return an Array but ALSO accept an array as input as the JScript declaration does. Any ideas? Am I approaching this wrong?
Thanks in advance.
Here is one of the original JScript functions:
function binl2byt(binarray)
{
var hex_tab = "0123456789abcdef";
var bytarray = new Array(binarray.length * 4);
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
bytarray[i] = (binarray[i>>2] >> ((i%4)*8+4) & 0xF) << 4 | binarray[i>>2] >> ((i%4)*8) & 0xF;
}
return bytarray;
}
Here is what I have in VB.NET so far:
Public Function binl2byt() As Array(byval binarray as array)
Dim hex_tab As String = "0123456789abcdef"
Dim bytarray() As Byte
Dim str As String = ""
For I As Integer = 0 To (bytarray.Length * 4) Step 1
bytarray(I) = ((binarray(I >> 2) >> ((I Mod (4)) * 8 + 4) & Oxf) << 4) Or (binarray(I >> 2) >> ((I Mod (4) * 8) & OxF))
Next
Return bytarray
End Function
There is no need for this function, it is already there in .NET for you.
BitConverter.ToString(Bytes);
Where Bytes is your byte array.
精彩评论