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

Top 5 Contributors of the Month
Easy Web
Imran Ghani

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


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();


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

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


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();


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

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