473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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??
Mar 9 '10 #1

✓ answered by GaryTexmo

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...
Expand|Select|Wrap|Line Numbers
  1. Employee newEmployee = Add();
  2. Show(newEmployee);
where Add and Show are defined as follows...

Expand|Select|Wrap|Line Numbers
  1. Employee Add() { ... }
  2. void Show(Employee employeeToShow) { ... }
An MSDN link on parameter passing...
http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

2 2448
GaryTexmo
1,501 Expert 1GB
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...
Expand|Select|Wrap|Line Numbers
  1. Employee newEmployee = Add();
  2. Show(newEmployee);
where Add and Show are defined as follows...

Expand|Select|Wrap|Line Numbers
  1. Employee Add() { ... }
  2. void Show(Employee employeeToShow) { ... }
An MSDN link on parameter passing...
http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
Mar 9 '10 #2
tlhintoq
3,525 Expert 2GB
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.
Mar 9 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ekim | last post by:
my question is as follows: I've got a DLL in which I have a method GetBuffer (this one is extern, exported, is called from outside this program) which shall pass a char-buffer to the...
9
by: Alvin Bruney | last post by:
The more knowledgable I get about this .net world, the more questions I have. ..NET uses pass by reference for all objects....uhhh I mean pass by value. (Couldn't resist this jab) Consider a...
1
by: Jeffrey B. Holtz | last post by:
I'm trying to get the Name of the USB device pluged in from the RegisterDeviceNotification that I've used P/Invoke to marshal. I have seen a similar posting on the VisualBasic newgroups but I do...
4
by: z_learning_tester | last post by:
I'm reading the MS press C# book and there seems to be a contradiction. Please tell me which one is correct, 1 or 2. Thanks! Jeff 1. First it gives the code below saying that it prints 0 then...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
21
by: vmsgman | last post by:
Here is a code sample ... int blah = ReadFile( defArray, defFileName, w, h); // Read File Contents into memory array and return for processing public int ReadFile( ref ushort nArray, string...
2
by: Brett | last post by:
How do I receive command line parameters being passed into my application? Say I call the application from within MS Access and it passes me an ID. How do I receive the ID in the VB.NET app? ...
4
by: DaBrain | last post by:
Win32 C++/Delphi Developer here moving to .NET C# (Yes, I'm a newbie again) Thank you all for any replies in advance. I am developing a class that accesses a record, one record, and sets the...
13
by: Francois Appert | last post by:
This post was originally in the C# Corner site, but their server is down. I'd like to see if this group can answer. I program in C++ and am learning C#. The issue is: why should anybody...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.