Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ref Array

ref Array

Scheduled Pinned Locked Moved C#
questioncsharpcomdata-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi, I am using a com object which maybe developped by VC6 or VB6. There is a method after wrapped by .Net like this: System.Array func(ref System.Array a); When I tried to pass the variable like this: Array a = new Array(); Array b = new Array(); b = func(ref a); It can not compile through? How can I make it work? Thanks in advance.

    L 1 Reply Last reply
    0
    • A Anonymous

      Hi, I am using a com object which maybe developped by VC6 or VB6. There is a method after wrapped by .Net like this: System.Array func(ref System.Array a); When I tried to pass the variable like this: Array a = new Array(); Array b = new Array(); b = func(ref a); It can not compile through? How can I make it work? Thanks in advance.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Anonymous wrote: When I tried to pass the variable like this: Array a = new Array(); Array b = new Array(); Try:

      object[] a = new object[1];
      object[] b;

      xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

      Y 1 Reply Last reply
      0
      • L leppie

        Anonymous wrote: When I tried to pass the variable like this: Array a = new Array(); Array b = new Array(); Try:

        object[] a = new object[1];
        object[] b;

        xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

        Y Offline
        Y Offline
        yyf
        wrote on last edited by
        #3

        Here is what I did: object []a = new object[1]; object []b; Array tmp = (Array)a; b = (object [])func(ref tmp); Then it compiled ok. But when I run it, I got this exception: An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in GeoCoding.exe Additional information: Specified array was not of the expected type. Thanks.

        M 1 Reply Last reply
        0
        • Y yyf

          Here is what I did: object []a = new object[1]; object []b; Array tmp = (Array)a; b = (object [])func(ref tmp); Then it compiled ok. But when I run it, I got this exception: An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in GeoCoding.exe Additional information: Specified array was not of the expected type. Thanks.

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          What's the IDL declaration of func? Right now you're stuffing an array of generic objects into the function. I guess func doesn't expect an array of objects, but of other, more meaningful types. mav

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups