本文介绍了Vb.net变量范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在启动.aspx页面中声明了一个朋友变量。我也尝试将其声明为公共
我不能在整个项目中访问该变量吗?
我知道这应该很容易。但是我错过了一些东西。
我尝试了什么:
I've declared a Friend Variable in my start up .aspx page. I've also tried declaring it as Public
Shouldn't I be able to access that variable all across the project?
This should be easy I know. But I'm missing something.
What I have tried:
Class _Default
Inherits System.Web.UI.Page
Friend testVar as string = "something"
End Class
在另一个.aspx页面我试试 -
In another .aspx page I try -
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim readtestVar = testVar
End Sub
产生错误'未声明testVar。由于它的保护级别,它可能无法访问。'
推荐答案
这篇关于Vb.net变量范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!