Click here to Skip to main content
15,889,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am running project in windows, and i have used public static int id to access it publically on another forms, like session in winform.
but the problem is i cant clear that value for another entry.
can u suggest any solution to clear this.

What I have tried:

public static int id;
and used it in another page as id
Posted
Updated 8-Jul-16 2:53am
Comments
John C Rayan 8-Jul-16 8:38am    
what you mean by 'you can't clear'. Are you trying to assign 0?
You have to remember that static is different from instance variables. Static variable holds only one value across all instances.

So if you requirements need different values to different instances then you have to make it non-static.
BillWoodruff 9-Jul-16 13:29pm    
Not clear what you are doing here. Please describe what your WinForm app does; it has a Main Form that creates other secondary Forms; you are using Form inheritance ?
Member 12224208 11-Jul-16 7:57am    
Thanks Jhon i think u solved my problem..i will try this by making my variable non static.

1 solution

Hi

You can set the value 0 or overwrite new value.
 
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