How do u declare static variable and how it is declared and what is its lifetime?



How do u declare static variable and how it is declared and what is its lifetime?..

Answer / Abhinaya Bhullar

In C#, a static variable is declared with the 'static' keyword. Here's an example: `private static int myStaticVariable = 0;` The variable will be created once when the class is loaded by AppDomain and exist for the lifetime of that application domain.nnThe lifetime of an application domain can vary depending on how it was created, but typically it persists until the last user closes the application.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Explain the asp.net mvc request life cycle? : asp.net mvc

1 Answers  


What is difference between asp state management and asp.net state management? How can we pass info between 2 asp.net pages?

1 Answers  


What is the lifespan for items stored in ViewState?

4 Answers   Siebel Systems,


what is SQL cache Invalidation?

1 Answers  


What is the difference between and ActiveX dll and control?

2 Answers   Microsoft,


with which controls you worked in Asp.net 2.0?

2 Answers   HP, nTech Solutions,


Fetch one page value to another page without using state-managment ?

1 Answers   HCL,


Below is a code extract from an ASP.Net application. The code basically reads data from the “name” field in the “members” table and prints them onto the webpage. Using the assumptions provided, fill in the 4 blanks below so that the code will run correctly. ‘Assumptions: ‘conn_str is a variable that holds the connection string to the database ‘Objects dbcomm and dbread are already declared earlier dbcomm = New OleDbCommand("SELECT name FROM members", conn_str) dbread = dbcomm._______________ _____________________ response.write(_______________) _____________________ dbread.Close()

4 Answers   Techno Solutions,


How to identify host of my system? How to identify servername of my system? How to identify domainname of my system?

2 Answers  


Why do we use Option Explicit?

2 Answers   Microsoft,


Explain the difference between Web Garden and Web Farm?

1 Answers   Sans Pareil IT Services,


What is the life cycle of web page?

1 Answers  


Categories