Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A

ASP.NET interview questions with answers: - Difference between Application Vs Static

Application State is a kind of state management technique in which let you save the state of current application. Some points which need to be known about Application variables

  • It is stored in server memory.

  • It will be faster than storing and retrieving values from database.

  • Unlike session state which is specific to a single user session, application state is available to all users and sessions.

On the second place, static variables severs the same purpose.

  • If we declare any variable as static it will retain the memory till our application is running. In short life of static variable is equal to life of application.

  • Like Application, They will be available to all users and sessions.

How both are different then?

  • From Performance point of view I will prefer static, because static variables provide type safety.

  • Compile time error check for wrong values also makes static variables better than application variables.

  • When it comes to locking Application variables are better choice, because Applicatin.Lock method will lock all application variables, whereas in case of static separate synchronization logic is required for every variable. But if you want to lock only one application level values static wins over application variables.

  • Last but not the least, application variables wins when it comes to migration from classic asp to because classic asp won’t have support for static variables.

Do see the below video on ASP.NET MVC interview questions Video which discussed the difference between viewdata,viewbag,tempdata and session variables.

Tags: application vs static, interview questions with answers, csharp interview questions, information technology questions, programming interview questions

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded