returning more than one value....in .NET(C#).

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tirumalab
    New Member
    • Apr 2007
    • 21

    returning more than one value....in .NET(C#).

    Hi all,

    How can we catch the return values if the function, which takes out parameters, is going to return more than one value in C#.

    Ex: public int addparams(out int x,out int y)
    {
    Int someinteger;

    //code

    return someinteger ;
    }
    Requesting you all kindly plz find some time and tell me, Is this method returns more than one value,if so how can catch that return values.

    Thanks in advance..

    regards,
    tirumala.
  • hbxtlhx
    New Member
    • Sep 2007
    • 10

    #2
    Originally posted by tirumalab
    Hi all,

    How can we catch the return values if the function, which takes out parameters, is going to return more than one value in C#.

    Ex: public int addparams(out int x,out int y)
    {
    Int someinteger;

    //code

    return someinteger ;
    }
    Requesting you all kindly plz find some time and tell me, Is this method returns more than one value,if so how can catch that return values.

    Thanks in advance..

    regards,
    tirumala.
    return struct or class.
    example:

    struct A
    {
    public int a;
    public int b;
    public int c;
    }
    public A addparams(out int x,out int y)
    {
    Int someinteger;

    //code
    A a=new A();
    a.a=1;
    a.b=2;
    a.c=3;
    return a;
    }

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by tirumalab
      Hi all,

      How can we catch the return values if the function, which takes out parameters, is going to return more than one value in C#.

      Ex: public int addparams(out int x,out int y)
      {
      Int someinteger;

      //code

      return someinteger ;
      }
      Requesting you all kindly plz find some time and tell me, Is this method returns more than one value,if so how can catch that return values.

      Thanks in advance..

      regards,
      tirumala.
      I suppose you do have a C# textbook with you right?
      What does it say about that. If it doesn't have that topic in it then shame on the author and shame on the teacher who recommended it.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by hbxtlhx
        return struct or class.
        example:

        struct A
        {
        public int a;
        public int b;
        public int c;
        }
        public A addparams(out int x,out int y)
        {
        Int someinteger;

        //code
        A a=new A();
        a.a=1;
        a.b=2;
        a.c=3;
        return a;
        }
        So why use out parameters then?

        Comment

        • hbxtlhx
          New Member
          • Sep 2007
          • 10

          #5
          int xvar=0;
          int yvar=0;
          int retvar=0;

          retvar = addparams(out xvar,out yvar);

          Console.WriteLi ne(xvar);
          Console.WriteLi ne(yvar);
          Console.WriteLi ne(retvar);

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by hbxtlhx
            int xvar=0;
            int yvar=0;
            int retvar=0;

            retvar = addparams(out xvar,out yvar);

            Console.WriteLi ne(xvar);
            Console.WriteLi ne(yvar);
            Console.WriteLi ne(retvar);
            1.) Please use code tags if you have to post code.
            2.) I'm not sure what you're trying to achieve with this code but if you're referring to the OP's question then the best thing is simply to read about these things like I've already said.

            Comment

            Working...