Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I used a couple of strings in my one forms and
now need those values of those string
in the rest of my forms. How can I do this?

Here is my strings I use:

public string strUsername;
        public string strPassword;
        public string strLog;


Please any help would be appriciated
Posted

1 solution

Well if you are using only one instance of the variables above, you can just simply declare a static class which holds them in a common location. This can also be used as a Helper class containing common static methods which are required everywhere.

Steps:

1. Have a common namespace: Namespace.Common
2. Declare a static class like: public static HelperClass
3. Declare your variables here
4. Use them throughout your application
 
Share this answer
 
v2
Comments
Ben Paxton 5-Mar-12 1:49am    
Sorry, but doesn't explain much.
Nithin Sundar 5-Mar-12 1:55am    
Updated solution. Check it. There's little to explain.

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