Click here to Skip to main content
15,905,782 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Hello, I did a code which have an integer value in a block. I have passed this value to another block on button click event but I want to pass the same integer value to the 3rd block. I did this code :

C#
void wc_DownloadStringCompleted1(object sender, DownloadStringCompletedEventArgs e)
{
    ...
    dynamic num = label1.Bottom + (i * 30);
    button1.Click += new EventHandler((sender1, e1) => button1_Click(sender, e, num);
}

I have passed this integer value to the following code :

C#
void browsebutton_Click(object sender, DownloadStringCompletedEventArgs e, int num)
{
    ...
    wc.DownloadStringCompleted += wc_DownloadStringCompleted2;
//[In its place I also tried this : wc.DownloadStringCompleted +=new     //DownloadStringCompletedEventHandler((sndr, ev) => wc_DownloadStringCompleted2(sender, e, //num)); but when I used this the control is not going to the 3rd block]
}

Now I want to pass that num value to the following block
C#
void wc_DownloadStringCompletedbrowse2(object sender, DownloadStringCompletedEventArgs e)
{
   ....
}


Please any one give me any suggestion.

Thanks.
Posted
v2
Comments
BillWoodruff 4-Apr-14 1:19am    
I see several reasons your code will not compile as is. I recommend you step back from coding, and write a clear statement of what your goal is here. Then revise your question, and include any error messages you get when you compile the code. Show the code where the error occurs.
Priyanka Bhawsar 4-Apr-14 1:37am    
Thanks, but I am not getting any error, I just want to pass 'num' integer value.

1 solution

Change num into a member variable of the class, it will be accessible from all functions/properties of that class then.
 
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