Solved

How can I pass parameter values from function to function?

Posted on 2006-11-27
2
261 Views
Last Modified: 2010-04-16
Hi,

As what I state in the title, I want to know how can I pass parameter values...
Here is what I have in my codes...

public struct TypeA
{
 string name;
 int value;
}
public void Function123(int paramA, TypeA paramB)
{
 // here I try to get paramA and paramB values
}

public void Main
{
  TypeA target;
  int index;

  Function123(index, target);   <-- here I try to get values from this function but the values seem not passed through the function
}

How exactly I should do to pass parameter values??
0
Comment
Question by:xenia27
2 Comments
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 18025383
Not exactly clear what you are trying to achieve.

First, your variables are not initialized.
To pass your values to the function you need to create new struct instance and initialize integer.

If you are going to change your variables inside the function and want to see the changes afteryour  function invocation
you may use passing parameters by reference. However you need to declare your function appropriately;

        public void Function123(ref int paramA, ref TypeA paramB)
        {
            // here I try to get paramA and paramB values
        }

and in Main you invoke:

Function123(ref index, ref target);
0
 

Author Comment

by:xenia27
ID: 18026046
this is exactly what I try to figure out..thanks~
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now