开发者

ASP.NET: concept question regarding variable declaration

开发者 https://www.devze.com 2023-01-04 00:15 出处:网络
consider this code: Partial Public Class MyAspNETClass Inherits System.Web.UI.Page Protected Shared MyVariable As String

consider this code:

Partial Public Class MyAspNETClass
Inherits System.Web.UI.Page

Protected Shared MyVariable As String
....
....

2 questions:

  1. Is Myvariable a variable used local for each instance of the page ? Or that variable is "shared" for all users accessing my page ?
  2. Is MyVariable sa开发者_如何学运维ved in server memory, or is it saved on the viewstate of aspx page ?

This is 2 doubt i can't answering by myself, so i'm asking you ! Thanks


Because MyVariable is Shared it will be allocated in memory only once and shared by every instance of the class.

It is not stored in the ViewState

0

精彩评论

暂无评论...
验证码 换一张
取 消