.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

oops

Posted By: sriram     Posted Date: January 11, 2010    Points:2   Category :.NET Framework
i have one class in app_code. what is the best way to create object of that class in .aspx.cs.

im doing as follows:
before page_load declaring reference of that class as
CommonClasses objCommon = null;
and in every method where ever im using that class creating object as
objCommon = new commonClasses();

(or)

creaing objecting before page_load itself as
CommonClasses objCommon = new commonClasses();

would anyone help me which is the best one or is thr any other better way to create object

Responses
Author: Amit Mehra             
Posted Date: January 11, 2010     Points: 5   

Hi,

I will go with the 1st method with little changes.. Declare 1st with null

CommonClasses objCommon = null;



than in each method check the object null or not

if(objCommon ==null)
{
objCommon = new commonClasses();
}


Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend