return-type

Returning an objects subclass with generics.

With an abstract class I want to define a method that returns "this" for the subclasses: public abstract class Foo { ... public <T extends Foo> T eat(String eatCake) { ... return this; } } public class CakeEater extends Foo {} I want to be able to do things like: CakeEater phil = new CakeEater(); phil.e...

To send an object with its xml schema

All we are using web services. I want to send generic result from my function as a result. I can set its return type as an object type. I wonder that, can i create(generate) xml schema of my return type runtime? for ex: [Serializable] class NewClass{} [Serializable] class OldClass{} [WebMethod] public object fFunctionN...

How can I send ArrayList over Web Service?

Subject is my real question but i wonder that another issue about web services. What is the key points of web services to return something? Serializable (Because everything converts to XML before adding them to SOAP Message) ? (What should i do for generic class) ?? (How can i put everything (which are serializable classes) to one ret...

Same class comes within different web services

I have 3 different web services work with same class library. These three web services return same class type object. But on the client side, I'm getting 3 different object type even they are same. I can't treat them like one class type. I think i will add a method which can take object and sets properties with object's props. Is the...

Unknown return type for a C function.

I am writing a library for C, and one function can return either a string (char *), an integer or a double. Next to that, the length of the string is unknown. I really don't know how to deal with this problem. I thought about using pointers as arguments to the function but that is really messy. Can anyone give me a solution, and maybe s...

Is it better to return the most specific or most general type from an action method?

What are the benefits or detriments of either? ...

PHP: cast to (array) and return-type: array is not the same?!

Hi! I have following problem in PHP: print_r says its the same, gettype says same type.. but the last output works not for both cases... although they should be the same!! this looks very strange for me... code and output: $docdatau = get_object_vars(json_decode($docdata)); $docdatau2 = (array)json_decode($docdata); echo "1\n"; echo...

Linq to Sql method return type

I have a stored procedure that has FOR XML AUTO and I use it in a dbml file. The problem is that I want the return type to be XDocument. For now it returns the xml string cut into pieces. I can use someting like : foreach(spMyProcedure_GetResult getResult in list) { sb.Append(getResult.XML_F52E2B61_18A1_11d1_B105_00805F49916B); }...

Is it possible to *safely* return a TCHAR* from a function?

I've created a function that will convert all the event notification codes to strings. Pretty simple stuff really. I've got a bunch of consts like const _bstr_t DIRECTSHOW_MSG_EC_ACTIVATE("A video window is being activated or deactivated."); const _bstr_t DIRECTSHOW_MSG_EC_BUFFERING_DATA("The graph is buffering data, or has stopped bu...

multiple output parameters in .NET web service (without complex type)

Is it possible to create an C# web service which returns multiple strings, without generating a complex type? (Because my client can't handle complex types and I need to return exactly 2 strings with the names: "wwretval" and "wwrettext") I've already tried to create a struct or a class or do it with out params, but it always generated...

Why doesn't Java 5+ API take advantage of covariant return types?

Since Java 5 we are allowed to have covariant return types. Why doesn't the Java API take advantage of this? Take Graphics2D.create() for instance. Why isn't it overridden to return a Graphics2D object? It seems to me that it would be backward compatible in all situations. ...

Is this an Exception Handling abuse?

I have this method, that can return three different response. At first, it was supposed just only return two, so I make its return type to Boolean like: public static boolean isLoteWaitingForImage() And some business logic came out with that it can has another result, so the method was modified to public static boolean isLoteWaitin...

Unable to return custom class from WCF Data Service

I am trying to return a custom class from my WCF data service. My custom class is: [DataServiceKey("ID")] public class Applist { public int ID { get; set; } public string Name { get; set; } } My data service looks like: public static void InitializeService(IDataServiceConfiguration config) { config.RegisterKnownType(typeo...

Does a C++ method definition in a class have to specify the return type?

Just saw this question relating to a segmentation fault issue in a C++ class and program. My question relates to the class definition. Here it is as it was posted: class A { int x; int y; public: getSum1() const { return getx() + y; } getSum2() const { return y + getx(); } get...

In Java, How do I return a String or a double depending on the circumstance of the method? Is it possible?

For example, I have a method that looks through a string for data separated by a specified deliminator, but some items might be a names, and other items might be numbers. If a user calls my method to return item number X from the deliminated list, i want it to return a string if item X is a name, or a double if item X is a number. For ...

In Perl, how can I return a tied hash from a subroutine?

I want to have a perl subroutine that creates and returns an ordered hash via the Tie::IxHash module. It looks something like this: sub make_ordered_hash { my @hash_contents = munge_input(@_); # I get a list of alternating keys and values tie(my %myhash, Tie::IxHash, @hash_contents); return %myhash; } Now, if I do my %orde...

Return from a C++0x lambda caller directly

I've just rewritten the following C89 code, that returns from the current function: // make sure the inode isn't open { size_t i; for (i = 0; i < ARRAY_LEN(g_cpfs->htab); ++i) { struct Handle const *const handle = &g_cpfs->htab[i]; if (handle_valid(handle)) { if (handle->ino == (*inode)->i...