Hi Gergory,
Thanks for posting in the community.
CASE 1
Public Case1 As Byte()
declare an Case1 as an type Byte array
CASE 2
dim Case2() As Byte
Same as above, except you can define the boundlist in the parentheses in
this method.
Case 3
dim Case3 as new Byte()
This line will become dim Case3 as new Byte
This will call the new instance of Byte type.
[ <attrlist> ] [{ Public | Protected | Friend | Protected Friend |
Private | Static }] [ Shared ] [ Shadows ] [ ReadOnly ]
Dim [ WithEvents ] name[ (boundlist) ] [ As [ New ] type ] [ = initexpr ]
For detailed information take a look at the link below.
Dim Statement
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/
vastmdim.asp
Here is the code in VB.NET
Sub Main()
Dim Case1 As Byte()
Dim Case2() As Byte
Dim Case3 As Byte
Dim Case4 As New Byte
End Sub
The according IL language generated.
..method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01
00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init ([0] unsigned int8[] Case1,
[1] unsigned int8[] Case2,
[2] unsigned int8 Case3,
[3] unsigned int8 Case4)
IL_0000: nop
IL_0001: ldloca.s Case4
IL_0003: initobj [mscorlib]System.Byte
IL_0009: nop
IL_000a: ret
} // end of method Module1::Main
So Case1 and Case2 are of the same type. So do with the Case3 and Case4.
It seems that you wants to copy and byte array from one to another. If I
misunderstand your meaning, please feel free to post here.
Dim Case2(case1.length) as byte()
case1.copy(case1,case2,0)
I think the method will be ok.
'Declare Case1
Dim Case1 As Byte() = New Byte() {12, 34}
'Allocate the memory for Case2
Dim Case2(Case1.Length) As Byte
'Use the Copy function of Array to copy the data from case1 to case2
Array.Copy(Case1, Case2, Case1.Length)
'Change the data in Case1
Case1(0) = 100
'This will write out 12
Console.WriteLine(Case2(0))
If you still have any concern please post here.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.