X
xmail123
In a web service I am using a SqlDataReader to retrieve the
information to populate an ArrayList.
public ArrayList ReadHistory(int ItemPK)
{
SDrdr = SDcmd.ExecuteReader();
ArrayList AL = new ArrayList();
while(SDrdr.Read())
{
AL.Add(SDrdr["name"]);
}
return AL;
}
The web service is called from another project.
public ArrayList ReadHistory(int ItemPK)
{
wsrKeyCodeService.KeyCodeInformation WSR = new
wsrKeyCodeService.KeyCodeInformation();
ArrayList AL =
WSR.ReadKeyCodeHistory(VehiclePK);
return AL;
The problem is when I build the project I get the following error.
Cannot implicitly convert type 'object[]' to
'System.Collections.ArrayList'
When I change the type from ArrayList to Array…
public Array ReadHistory(int ItemPK)
{
wsrKeyCodeService.KeyCodeInformation WSR = new
wsrKeyCodeService.KeyCodeInformation();
Array AL = WSR.ReadHistory(ItemPK);
return AL;
}
The error goes away.
Apparently when the ArrayList is sent from the web service it is
converted to an Array.
Questions
1. Why does it do this?
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.
Thanks for the help.
information to populate an ArrayList.
public ArrayList ReadHistory(int ItemPK)
{
SDrdr = SDcmd.ExecuteReader();
ArrayList AL = new ArrayList();
while(SDrdr.Read())
{
AL.Add(SDrdr["name"]);
}
return AL;
}
The web service is called from another project.
public ArrayList ReadHistory(int ItemPK)
{
wsrKeyCodeService.KeyCodeInformation WSR = new
wsrKeyCodeService.KeyCodeInformation();
ArrayList AL =
WSR.ReadKeyCodeHistory(VehiclePK);
return AL;
The problem is when I build the project I get the following error.
Cannot implicitly convert type 'object[]' to
'System.Collections.ArrayList'
When I change the type from ArrayList to Array…
public Array ReadHistory(int ItemPK)
{
wsrKeyCodeService.KeyCodeInformation WSR = new
wsrKeyCodeService.KeyCodeInformation();
Array AL = WSR.ReadHistory(ItemPK);
return AL;
}
The error goes away.
Apparently when the ArrayList is sent from the web service it is
converted to an Array.
Questions
1. Why does it do this?
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.
Thanks for the help.