Simple C# question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parkc
    New Member
    • Feb 2007
    • 12

    #1

    Simple C# question

    After you return a value from a method, how do you use the value returned in another method?

    public string methodname()
    {
    return stringname;
    }

    public string anothermethodna me()
    {
    //use return value from 1st method in this method + "endingprefixna me"
    }
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Originally posted by parkc
    After you return a value from a method, how do you use the value returned in another method?

    public string methodname()
    {
    return stringname;
    }

    public string anothermethodna me()
    {
    //use return value from 1st method in this method + "endingprefixna me"
    }
    consider:
    Code:
    public string methodname()
    {
       return "mr";
    }
    public string method2()
    {
       return methodname()+". Jones";
    }
    
    
    
    string AName=method2();
    //AName ="mr. Jones"

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by parkc
      After you return a value from a method, how do you use the value returned in another method?

      public string methodname()
      {
      return stringname;
      }

      public string anothermethodna me()
      {
      //use return value from 1st method in this method + "endingprefixna me"
      }
      If I may, er, reading a tutorial/book wouldn't hurt too at this point.

      Comment

      • parkc
        New Member
        • Feb 2007
        • 12

        #4
        I couldn't find it in the book. Thanks everyone for the help.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by parkc
          I couldn't find it in the book. Thanks everyone for the help.
          I suggest that you throw away that book and get the C# language specification instead.

          Comment

          Working...