Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing properties in this style "[xxxx]"

Status
Not open for further replies.

KevoMee

Technical User
Apr 30, 2002
72
IE
I think it involves the IEnumerable interface but I want to be able to access the property names of my class in this style:

class["propertyname"]

where it can return a string, date or number. Any pointers?
 
Indexers:
Although you must declare the indexer as:

public Object this[ String sPropName]
{
get
{
//check sPropName to see which property must be read and return the result accordingly
}
set
{
// Set codes goes here, same as above only this time set the property.
}
}


The disadvantage is that you must return Object (casting, boxing..)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top