菜鸟问题,大家教教我~
本人刚开始学习,是个菜鸟,刚接触到类~
问题: 我在一个页面中
Partial Class _Default
Inherits System.Web.UI.Page
Class vcd
Public size As Integer
Dim w As Integer
Public color As String
Public p As HttpResponse
Property width() As Integer
Get
Return w
End Get
Set(ByVal value As Integer)
If value > 50 Or value < 10 Then
w = 50
Else
w = value
End If
End Set
End Property
Sub play()
p.Write("<br>开始播放")
End Sub
End Class
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim a As New vcd
a.size = 50
a.color = "黑色"
Response.Write("你购买的VCD大小是:" & a.size & ",颜色是:" & a.color & "")
a.width =
Response.Write("<br>width属性是:" & a.width)
a.p = Response
a.play()
End Sub
End Class
这样没问题
但是我把
Partial Class _Default
Inherits System.Web.UI.Page
Class vcd
Public size As Integer
Dim w As Integer
Public color As String
Public p As HttpResponse
Property width() As Integer
Get
Return w
End Get
Set(ByVal value As Integer)
If value > 50 Or value < 10 Then
w = 50
Else
w = value
End If
End Set
End Property
Sub play()
p.Write("<br>开始播放")
End Sub
End Class
上面这一段 单独放在一个类文件里
然后 用imports vcd 引入
就说size,color 不是改页面的成员了
我是菜鸟 问问 是不是不能把下面那段代码 单独放一个类里 一定要在同一个页面上