Visual Studio.NET 2003 generates type object[] for ArrayList method return

J

JDeats

I've noticed what appears to be a bug in the Visual Studio.NET (1.0
and 2003 versions). If I declare a web method like so:

[WebMethod]
public ArrayList GetMyList()
{
ArrayList list = new ArrayList()
list.Add("one");
list.Add("two");
return list;
}


If I bind to the above from a client application like so:

ArrayList newlist = mywebservice.GetMyList();

The above fails (sometimes, sometimes it works), the compiler expects
a type of object[] (object array) and not ArrayList. Casting also
fails. I've even tried the following:


[WebMethod]
public object[] GetMyList()
{
ArrayList list = new ArrayList()
list.Add("one");
list.Add("two");
return list.ToArray();
}

Sometimes it works, sometimes it doesn't work. The later example never
works. Can anyone explain this? Is it a IDE generated code bug?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top