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. Web Development
  3. ASP.NET
  4. Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList

Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList

Scheduled Pinned Locked Moved ASP.NET
questiondata-structureshelp
4 Posts 3 Posters 1 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.
  • S Offline
    S Offline
    samy100
    wrote on last edited by
    #1

    Hi, i am trying to use in my client application a web service that retuurns an arrylist. this is my code ArrayList b = new ArrayList(); b = newService.GetList(); when i try to compile it i get this message: Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList what is the problem? how can i get the array list from the webservice? thanks

    C R 2 Replies Last reply
    0
    • S samy100

      Hi, i am trying to use in my client application a web service that retuurns an arrylist. this is my code ArrayList b = new ArrayList(); b = newService.GetList(); when i try to compile it i get this message: Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList what is the problem? how can i get the array list from the webservice? thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The problem is that you are returnin an object[] and you need to convert or cast it.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • S samy100

        Hi, i am trying to use in my client application a web service that retuurns an arrylist. this is my code ArrayList b = new ArrayList(); b = newService.GetList(); when i try to compile it i get this message: Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList what is the problem? how can i get the array list from the webservice? thanks

        R Offline
        R Offline
        ReactiveX
        wrote on last edited by
        #3

        Your GetList() function in your web-service hasn't been defined properly. Make sure that the return type is an ArrayList public System.ArrayList GetList() { }

        Daniel Minnaar Lead Software Developer

        S 1 Reply Last reply
        0
        • R ReactiveX

          Your GetList() function in your web-service hasn't been defined properly. Make sure that the return type is an ArrayList public System.ArrayList GetList() { }

          Daniel Minnaar Lead Software Developer

          S Offline
          S Offline
          samy100
          wrote on last edited by
          #4

          this is my webservice: [WebMethod] public ArrayList GetDevicesList() { Hashtable DeviceList = new Hashtable(10); for (int i = 0; i < 10; i++) { DeviceList.Add("test"+i.ToString(),"test"); } ArrayList a = new ArrayList(); a.Add(DeviceList); return a; } of course my hash table will later be set with real values, but for now i am just testing my architecture. so it does return ArrayList. how can i use it from my client?

          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