473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

how to deal with a method that returns object array?

hi there,
i have a following method which returns array of object.

public myresult[] getSearch(string searchterm)
{
object[] res = ....some external method call
return ((myresult[]) (res[0]));
}

so my question is... how do i consume the above method? can i do the
following?
myresult[] res = getSearch("hello");

thanks...a
Mar 8 '07 #1
5 2842
VJ
Sure... or you could do a foreach on the item collection...

VJ

"Ace" <Ac*@discussions.microsoft.comwrote in message
news:B6**********************************@microsof t.com...
hi there,
i have a following method which returns array of object.

public myresult[] getSearch(string searchterm)
{
object[] res = ....some external method call
return ((myresult[]) (res[0]));
}

so my question is... how do i consume the above method? can i do the
following?
myresult[] res = getSearch("hello");

thanks...a

Mar 8 '07 #2
Ace <Ac*@discussions.microsoft.comwrote:
hi there,
i have a following method which returns array of object.

public myresult[] getSearch(string searchterm)
{
object[] res = ....some external method call
return ((myresult[]) (res[0]));
}

so my question is... how do i consume the above method? can i do the
following?
myresult[] res = getSearch("hello");
Yes. Did you try it before posting? What went wrong?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 8 '07 #3
thanks bunch.
in fact, i tried it and it compiled and ran fine. however, the problem is
that res is null after making a call to getSearch() (which is a web service)
and i was not sure if i was doing it wrong or it is just supposed to be null.

btw, if i were to loop through this array, is it the correct syntax?

foreach (myresult x in res)
{
}

-a
"Jon Skeet [C# MVP]" wrote:
Ace <Ac*@discussions.microsoft.comwrote:
hi there,
i have a following method which returns array of object.

public myresult[] getSearch(string searchterm)
{
object[] res = ....some external method call
return ((myresult[]) (res[0]));
}

so my question is... how do i consume the above method? can i do the
following?
myresult[] res = getSearch("hello");

Yes. Did you try it before posting? What went wrong?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 8 '07 #4
oh... all looks good now. it was just because the web service really did not
return any matches.
thanks all...a

"Ace" wrote:
thanks bunch.
in fact, i tried it and it compiled and ran fine. however, the problem is
that res is null after making a call to getSearch() (which is a web service)
and i was not sure if i was doing it wrong or it is just supposed to be null.

btw, if i were to loop through this array, is it the correct syntax?

foreach (myresult x in res)
{
}

-a
"Jon Skeet [C# MVP]" wrote:
Ace <Ac*@discussions.microsoft.comwrote:
hi there,
i have a following method which returns array of object.
>
public myresult[] getSearch(string searchterm)
{
object[] res = ....some external method call
return ((myresult[]) (res[0]));
}
>
so my question is... how do i consume the above method? can i do the
following?
myresult[] res = getSearch("hello");
Yes. Did you try it before posting? What went wrong?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 8 '07 #5
Ace <Ac*@discussions.microsoft.comwrote:
thanks bunch.
in fact, i tried it and it compiled and ran fine. however, the problem is
that res is null after making a call to getSearch() (which is a web service)
and i was not sure if i was doing it wrong or it is just supposed to be null.
Well, to check whether that kind of thing is valid or not, I'd suggest
trying it in a simpler environment first.
btw, if i were to loop through this array, is it the correct syntax?

foreach (myresult x in res)
{
}
Yes.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: limodou | last post by:
I found it puzzled me that: class A: def __getattr__(self, name): return None a=A() b=A() a==b will raise Exception: __eq__
10
by: lkrubner | last post by:
I killed last night and a good chunk of today trying to figure out this one particular attempt to get a class and initialize it. My code is using a class method called getObject to include() a file...
0
by: Bartas | last post by:
Hi, I'am writting a simple SOAP client in python (2.4) using SOAPpy lib. I've met with this problem: when I want to send a list of complex type using some method from WebService(java,WAS), ...
5
by: Ian Meakin | last post by:
I am trying to consume a web service i have written. The web service returns to the client an array of objects. The web service when tested via inetrnet explorer retruns the correct xml data. I...
7
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
7
by: heavyone | last post by:
I am trying to write a removeFirst method for an ArrayList of the generic type. The removeFirst method is supposed to do a few things: 1) If the list is empty it throws an error. 2) It stores the...
4
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am a newbie to WCF so please forgive if this is an obvious question. I have the following. (Service contract) IEmployee public interface IEmployee { List<EmployeeGetEmployeeByID(string...
2
by: florian.loitsch | last post by:
hi, I'm having troubles understanding the meaning of the "valueOf" method, as described in the ECMA-262 (3rd Edition) standard. I quote (section 15.2.4.4, page 85): === "The _valueOf_ method...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.