Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / December 2005

Tip: Looking for answers? Try searching our database.

Object Properties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
abillmeier - 21 Dec 2005 15:42 GMT
I have created a custom object with several properties that use private
variables.   I used an object with properties so I could better control
validation and share the code between applications.

Is it possible to access object properties as if they were in a collection?
I would like to be able to retrieve and update the properties kinda like:
objectinstancename("propertyname")

Can this be done?  Do I need to handle this in a differnet manner or add
additional code to allow it?

Thanks in advance.
Ken Tucker [MVP] - 21 Dec 2005 18:06 GMT
Hi,

         Take a look at reflection.

http://msdn2.microsoft.com/en-us/library/t0cs7xez.aspx

http://msdn2.microsoft.com/en-us/library/system.reflection.propertyinfo.aspx

Ken
----------------------------

> I have created a custom object with several properties that use private
> variables.   I used an object with properties so I could better control
[quoted text clipped - 8 lines]
>
> Thanks in advance.
Chris Dunaway - 21 Dec 2005 19:56 GMT
> Is it possible to access object properties as if they were in a collection?
> I would like to be able to retrieve and update the properties kinda like:
> objectinstancename("propertyname")

Why?  Isn't

objectinstancename.propertyname

better than what you propose?  You get intellisense and it's fewer
character to type.  If you must access using a string, then reflection
will work for that, but it will more typing rather than less and more
prone to errors.
Branco Medeiros - 21 Dec 2005 20:23 GMT
<snip>
> Is it possible to access object properties as if they were in a collection?
> I would like to be able to retrieve and update the properties kinda like:
> objectinstancename("propertyname")
<snip>

VB.Net still supports the good old "CallByName" function:

 SomeValue = CallByName(Obj, "PropName", CallType.Get)

HTH.

Regards,

Branco.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.