静态变量在它声明的类的实例中每个会话存储不同的值 [英] does static variable store different value per session in the instance of the class where it declares

查看:97
本文介绍了静态变量在它声明的类的实例中每个会话存储不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hII,



i有一个类变量,它根据companyId向用户发送电子邮件,



假设我将compayId存储在静态变量中,当调用类方法时,每个会话都会有所不同



我很困惑何时使用静态变量这会在calss的整个范围内存储相同的值,有人说这里的值存储对于所有会话都是相同的...

hII ,

i have a class variable which sends email to users based on companyId,

Suppose if i store compayId in static variable will be differnt per session wise when that class methods will be invoked

I am very much confused when to use static variable as some says this stores same value throughout the istance of the calss , some says that value store in this will be same for all sessions ...

推荐答案

是的,静态值将保留所有用户都一样。如果一个用户正在更新该值,那么它也会反映给其他用户。



您可以使用查询字符串或任何其他状态管理从一个表单传递值到其他
Yes, static values will remain same for all users. if one user is updating that value, then it will be reflected to other users as well.

You can use querystring or any other state management to pass values from one form to other




静态varibale将在所有会话之间共享!因此,在您的情况下,您无法将id保存在静态变量中。
Hi,
the static varibale will be shared beetween all the sessions! So in your case you can't save the id in the static variable.


这篇关于静态变量在它声明的类的实例中每个会话存储不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆