Click here to Skip to main content
16,022,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just want to know the declaration of variables in a separate class file or declaring in the same aspx.cs file.Please any tell me the best practise of declaring the variables.
Thanks in advance
Posted
Updated 6-Oct-10 19:19pm
v2
Comments
Sunasara Imdadhusen 7-Oct-10 1:09am    
This is depending on your requirement like if you want to use value in more than one page then you can set in general file else aspx.cs file

Also you could use partial classes to separate parts of code logically. It's very useful to wrap all input controls into properties. For instance, for every TextBox control I create string property and have a deal just with properties at the page but not with such statements like these:

Product product=new Product(); 
product.Name=tbxProductName.Text; 


In my case it'll looks like:

product.Name=ProductName;

public string ProductName
{
   get{return tbxProduct.Text;}
   set{tbxProduct.Text=value;}
}


Please vote and Accept Answer if it Helped.
 
Share this answer
 
Maybe this[^] can help.
 
Share this answer
 
Here are few from me,

1. Use Camel[^] or Pascal[^] case while declaring variables,
2. Do not use variable having the same name with class and with same case.
3. Always prefer 'I' suffix while declaring interface.


Please vote and Accept Answer if it Helped.
 
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