Click here to Skip to main content
15,878,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have taken the input through keyboard using add function. How can I use the name stored in add function to display in a show function?
C#
static void add(employee em)
{
    Console.WriteLine("Enter Name");
    string name;
    name= Console.ReadLine();
    name = em.Name;
}

How can the name stored in name variable be used in a static show function to display name stored?

[Formatting]
Posted
Updated 1-Mar-10 21:34pm
v2

1 solution

Make it a member variable, or return it from the method. You will need to make the method not static to use a member variable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900