title: Array.copy method in vb.net
body: <pre><code> Public Shared Function EncryptRSA(ByVal infilename As String, ByVal outfilename As String, ByVal pubkey As String) As String
          Dim buffer2 As Byte()
          Dim buffer3 As Byte()
          Dim provider As New RSACryptoServiceProvider
          provider.FromXmlString(File.ReadAllText(pubkey))
          Dim sourceArray As Byte() = File.ReadAllBytes(infilename)
          Dim num As Integer = (sourceArray.Length / &amp;H3A)
          Dim stream As FileStream = File.Create(outfilename)
          Dim num2 As Integer = 0
  
          For num2 = 0 To num - 1
              buffer2 = New Byte(&amp;H3A - 1) {}
              Array.Copy(sourceArray, (num2 * &amp;H3A), buffer2, 0, &amp;H3A)
              buffer3 = provider.Encrypt(buffer2, True)
              stream.Write(buffer3, 0, buffer3.Length)
          Next num2
          If ((sourceArray.Length Mod &amp;H3A) &lt;&gt; 0) Then
              buffer2 = New Byte((sourceArray.Length Mod &amp;H3A) - 1) {}
  
              Array.Copy(sourceArray, ((sourceArray.Length / &amp;H3A) * &amp;H3A), buffer2, 0, (sourceArray.Length Mod &amp;H3A))
              buffer3 = provider.Encrypt(buffer2, True)
              stream.Write(buffer3, 0, buffer3.Length)
          End If
          stream.Close()
          Return File.ReadAllText(outfilename)
      End Function
  </code></pre>
  
  <p>Error   1   Overload resolution failed because no accessible 'Copy' can be called without a narrowing conversion:
      'Public Shared Sub Copy(sourceArray As System.Array, sourceIndex As Long, destinationArray As System.Array, destinationIndex As Long, length As Long)': Argument matching parameter 'sourceIndex' narrows from 'Double' to 'Long'.
      'Public Shared Sub Copy(sourceArray As System.Array, sourceIndex As Integer, destinationArray As System.Array, destinationIndex As Integer, length As Integer)': Argument matching parameter 'sourceIndex' narrows from 'Double' to 'Integer'.  C:\Users\user\AppData\Local\Temporary Projects\WindowsApplication1\Crypto.vb    52  13  WindowsApplication1</p>