Re: Copy: Hashtable to Properties
- From: "Andy" <ajohnstone@xxxxxxxxxxxxxxxx>
- Date: 21 Jun 2005 07:25:31 -0700
You'd have to use reflection, something like this:
Type objType;
PropertyInfo property;
objType = obj.GetType();
foreach( DictionaryEntry de in hash ) {
property = objType.GetProperty( de.key );
property.SetValue( obj, hash[ de.key ] );
}
You may have to cast the value out of the Hashtable to match what the
property expects, so you may need to have a switch statement in there
that looks at property.PropertyType.
HTH
Andy
.
- Follow-Ups:
- Re: Copy: Hashtable to Properties
- From: Adam Clauss
- Re: Copy: Hashtable to Properties
- References:
- Copy: Hashtable to Properties
- From: James Scott
- Copy: Hashtable to Properties
- Prev by Date: Cannot run any macros through Visual Studio 2003
- Next by Date: Re: hiding vs. overriding
- Previous by thread: Copy: Hashtable to Properties
- Next by thread: Re: Copy: Hashtable to Properties
- Index(es):
Relevant Pages
|