pass a string from one function to another in a console application??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemantc87
    New Member
    • Mar 2010
    • 13

    pass a string from one function to another in a console application??

    i am creating a menu driven application which goes like this
    1. Add an new employee
    2. Show employee
    3. Edit employee
    4. Delete Employee
    after i am able to add an employee through a function add() i m not able to display the value in 2nd option which has a function show.i am new to it and as far as i can say the variable looses its scope outside add function and nothing shows up in show(). What should i do??
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Don't take this to mean anything other than just a friendly suggestion, but are you unable to use parameters in your methods?

    Could you not...
    Code:
    Employee newEmployee = Add();
    Show(newEmployee);
    where Add and Show are defined as follows...

    Code:
    Employee Add() { ... }
    void Show(Employee employeeToShow) { ... }
    An MSDN link on parameter passing...

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Bytes has a policy regarding assisting students with their homework.

      The short version is that the volunteers here can't help you with schoolwork.
      A) We don't know what material you have and have not learned in class.
      B) We don't know the guidelines you must follow.
      C) In the long run giving you the answers actually short changes your education.

      Hint 1: Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.
      Hint 2: Your text book
      Hint 3: Your instructor
      Hint 4: Posting guidelines regarding homework assignments.

      Comment

      Working...