setting a property value using reflection

If the code below gets a property by constructing the property name how would i set it?

say i want to set the property availabilityMonth.Day07 = 12 for e.g?

how would i do that?

im trying something like:
dayAvailability.SetValue(_availabilityMonth, 2, Reflection.BindingFlags.SetProperty)

but not getting very far?
Dim dayAvailability As Reflection.PropertyInfo = Nothing
 
 dayAvailability = _availabilityMonth.GetType.GetProperty("Day" + monthDay.ToString())

Open in new window

scm0smlAsked:
Who is Participating?
 
omegaomegaConnect With a Mentor DeveloperCommented:
Hello, scm0sml,

It looks close.  Try replacing Reflection.BindingFlags.SetProperty with Nothing.  I.e. try:

    dayAvailability.SetValue(_availabilityMonth, 12, Nothing)

(I've also changed the second parameter, 2, to 12 to correspond better with your example.

Cheers,
Randy
0
 
scm0smlAuthor Commented:
good man.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.