2 Replies - 652 Views - Last Post: 05 July 2010 - 06:49 AM Rate Topic: -----

#1 MarkBrend   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-June 10

writing a dll and want to return a result back to the calling code.

Posted 05 July 2010 - 06:04 AM

Hi,

I am I have tried putting:-
public string oSQL2XStreamBridge( string Name)
public class string oMyDll
both of which it does not like...

the code below errors because there is a return statment and it says you can't have a return statement when it is set to void. but it will not let me set it to string (as above)

    public class oMyDll
    {                                    
        public oSQL2XStreamBridge( string Name)                                    
        {
            string ResultMess = "";

   	   // work code goes here

            return "Test";
        }
     }




How do I get the result back to the calling code?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: writing a dll and want to return a result back to the calling code.

#2 Bacanze   User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 202
  • Joined: 09-April 10

Re: writing a dll and want to return a result back to the calling code.

Posted 05 July 2010 - 06:33 AM

There is no return type declared in your method

public string oSQL2XStreamBridge( string Name)  


Remember, you have many return types in methods, bool, ints, generic list etc.

This post has been edited by Bacanze: 05 July 2010 - 06:33 AM

Was This Post Helpful? 2
  • +
  • -

#3 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: writing a dll and want to return a result back to the calling code.

Posted 05 July 2010 - 06:49 AM

    public class oMyDll
    {                                    
        public oSQL2XStreamBridge( string Name)                                    
        {
            string ResultMess = "";

   	   // work code goes here

            return "Test";
        }
     }





In your current code, your method is called oSQL2XStreamBridge(). What is that method supposed to return?

If you want to return that "Test" string you have to do the following:

public string oSQL2XStreamBridge(string Name)
{
    //Magic here.
    return "Test";
}



If oSQL2XStreamBridge is a type and you want to return an instance of that object type, then you have to give something like this:

public oSQL2XStreamBridge DoSomething(string Name)
{
    //return a oSQL2 object type.
}


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1