Saturday, March 31, 2012

Why is this property throwing a Overflow exception?

Hi I have made a property and its throwing an exception when I try and set its value. What is wrong with it. Please help.

Thanks

========================================

Public firstname As String

'Page_Load sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
name = ("John")
End Sub

'Name property
Public Property Name() As String
Get
firstname = Name
Return firstname
End Get
Set(ByVal Value As String)
Name = Value
End Set
End Property
End ClassYou may need change your code like this:


Dim firstname As String = ""
'Name property
Public Property Name() As String
Get
Return firstname
End Get
Set(ByVal Value As String)
firstname = Value
End Set
End Property

Thanks Jim. I,m packing up my books and going to bed I think. And can u beleive I just passed my MCP in asp.net this week lol.

My head hurts.

0 comments:

Post a Comment