PC Review


Reply
Thread Tools Rate Thread

Object Properties

 
 
abillmeier
Guest
Posts: n/a
 
      21st Dec 2005
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.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFR1Y2tlciBbTVZQXQ==?=
Guest
Posts: n/a
 
      21st Dec 2005
Hi,

Take a look at reflection.

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

http://msdn2.microsoft.com/en-us/lib...pertyinfo.aspx

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

"abillmeier" wrote:

> 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.
>
>
>

 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      21st Dec 2005
abillmeier wrote:

> 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.

 
Reply With Quote
 
Branco Medeiros
Guest
Posts: n/a
 
      21st Dec 2005

abillmeier wrote:
<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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deserialization - Can see object properties in Visual Studiointellisense but receive object refernce not set error. YZ Microsoft C# .NET 0 27th Jun 2011 10:19 AM
Re: continuous - want to change properties of object based on another object data Allen Browne Microsoft Access Form Coding 0 18th Jun 2008 05:04 AM
collection object not showing properties of stored object? =?Utf-8?B?UmljaA==?= Microsoft VB .NET 5 8th Nov 2006 06:51 PM
readonly properties when displaying an object's properties in propertygrid movieknight@gmail.com Microsoft VB .NET 0 14th May 2006 07:48 AM
How to access intrinsic WScript object properties from a .NET COM object Alek Davis Microsoft C# .NET 6 13th Aug 2004 10:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:20 PM.