Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2005, 12:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default Class Indexing

I'm not sure if this is the correct term for what I want to do but basically I have a Class, say, Users similar to:

Code:
Public Class clsUsers
    Private m_FirstName As String
    Private m_LastName As String
    Private m_EmailAddress As String

Public Property FirstName() As String
        Get
            Return m_FirstName
        End Get
        Set(ByVal Value As String)
            m_FirstName = Value
        End Set
    End Property
    Public Property LastName() As String
        Get
            Return m_LastName
        End Get
        Set(ByVal Value As String)
            m_LastName = Value
        End Set
    End Property
    Public Property EmailAddress() As String
        Get
            Return m_EmailAddress
        End Get
        Set(ByVal Value As String)
            m_EmailAddress = Value
        End Set
    End Property
'etc. more properties go here...
'************************************************
'Methods here for Adding, Removeing, Updating, etc.
'etc.

End Class
Now what I want to be able to do is set a Property of my User by doing somehting like:

Dim myUser as New clsUsers
myUser("FirstName").Value = "Joe"
myUser("LastName").Value = "Smith"

instead of:
myUser.FirstName = "Joe"
etc.


how to?


-------------------------
Beware of programmers with screwdrivers...
__________________
-------------------------
Beware of programmers with screwdrivers...
 
Old August 16th, 2005, 12:26 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Why? The second example of your code is the proper way.

 
Old August 16th, 2005, 06:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

I've got a Class for my data access and I want to set the properties of the "User" by way of the column name...

I want to do something like:

For Each Column in QueryResult
  myUser(ColumnName).Value = ColumnValue
Next

instead of having to do:
myUser.PropertyName1 = Column1Value
myUser.PropertyName2 = Column2Value
myUser.PropertyName3 = Column3Value
myUser.PropertyName4 = Column4Value
etc.

My reasoning is to make my class methods more generic, and to shorten my code.



-------------------------
Beware of programmers with screwdrivers...





Similar Threads
Thread Thread Starter Forum Replies Last Post
CANNOT APPLY INDEXING WITH [] pallone .NET Framework 2.0 7 April 8th, 2008 06:40 AM
indexing within grouping jkmyoung XSLT 3 November 15th, 2004 04:08 PM
indexing vohra_vikas SQL Server 2000 2 September 28th, 2004 11:49 PM
Indexing. kilika SQL Server 2000 3 May 24th, 2004 03:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.