Re: Code calls method with wrong signature (object vs object[])

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



LordHog@xxxxxxxxxxx wrote:
The strange item which I don't understand is that instead of call the
method that accepts an array of objects the code is calling the method
where the signature only accepts a single object. Can someone explain
why this is? My guess is since object is the base class of most items
it is also the base class for arrays. Any explanation will be
appreciated. For the time being I will just end up change the method
names to force call to the correct method istead of relying on the
compiler looking at the signature.

Changing the method names won't help you, as a byte[] isn't an
object[]. The problem is that while *arrays of reference types* are
covariant, arrays of value types aren't. For instance:

string[] stringArray = new string[10];
object[] objectArray = stringArray; // Fine

but

byte[] byteArray = new byte[10];
int[] intArray = byteArray; // No conversion available
object[] objectArray = byteArray; // No conversion available

The other posts give suggested solutions.

Jon

.



Relevant Pages

  • Problems with RSA.SignData
    ... large byte arrays and then write them to disk. ... The problem is when I am calling the SignData method within a loop for many ... Dim Signature() As Byte ... Dim RSA As RSACryptoServiceProvider ...
    (microsoft.public.dotnet.security)
  • COMException - Type Mismatch - VARIANT* and SAFEARRAY
    ... I'm trying to call a COM method that has the following signature: ... int32 Foobar; ... arrays and wrapping them in objects, ... C++/VB library that will accept the raw SAFEARRAY, wrap it, and pass it to ...
    (microsoft.public.dotnet.framework.interop)
  • OpenSSL DSA_do_verify equivalent
    ... I'm looking for a win32 equivalent to the below OpenSSL code, verifying a ... signature on a hash. ... P,Q,G,Y and R,S are given as byte arrays. ...
    (microsoft.public.platformsdk.security)
  • Re: OpenGL Optimization and Lighting
    ... the thought that 64K is sufficient to hold a high quality ... representation of a single object is a bogus assumption. ... arrays with 64K vertices are much too big anyway. ... After 512 triangles or so you the performance increase from ...
    (comp.graphics.api.opengl)
  • Re: Records and Arrays (#170)
    ... Here's aor -> roa adapter that works with any class, ... methods to the base class as they come, ...
    (comp.lang.ruby)