[thelist] tip: ASP.NET - Property Declarations

Chris Blessing webguy at mail.rit.edu
Thu Mar 21 17:48:10 CST 2002


<tip author="Chris Blessing" type="Setting up members in classes with
ASP.NET">

If you're new to the ASP.NET/VB.NET world, and you're an old-schooler with
VB6/VBS, you're going to run into some issues (as I did) when you're
creating your own classes.

When you setup properties for a class in VB6, you'd use LET and GET right?
Well those have been abolished from ASP.NET for a seemingly-better system.
Take this example:

property let ToAddress(ByVal strAddr as String)
	mstrAddr = strAddr
end property

property get ToAddress() as String
	ToAddress = mstrAddr
end property

In ASP.NET, you'd handle it like this, in one contained property block:

property ToAddress() as String
	get
		return mstrAddr
	end get

	set(ByVal strAddr as String)
		mstrAddr = strAddr
	end set
end property

Note that as usual, your property declaration needs to be of the same type
as your set statement.
</tip>

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net




More information about the thelist mailing list