Instance will be create only once for Data Access

In our .NET application we access to DB by DAL(Data Access Layer). Datamanager Class should be not be create more than once..coz it just occupy memory unnecessarily. We can define a method to check for any instance . If instance is exist Class will not create further object. Code is below:

Public Class DataManager()
{
private static DataManager _instance = null;
public static DataManager GetInstance
{
get
{
if (null == _instance)
_instance = new DataManager();
return _instance;
}
}
}

Comments

Popular Posts