Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

How can I pass parameter values from function to function?

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
xenia27
Asked:
xenia27
1 Solution
 
anarki_jimbelCommented:
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
 
xenia27Author Commented:
this is exactly what I try to figure out..thanks~
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now