Building Dynamic Properties at Runtime in VB.NET
Is there a way to dynamically create properties at runtime in VB.NET using introspection?
eg. Suppose I had a class
Public Class Foo
Public Property Bar() As String
get
...
end get
set(ByVal value As String)
...
end set
End Class
Is there a way to create a property bar at runtime?
Thank!
+2
source to share
4 answers
Unfortunately, there is no way to change the structure of a class at runtime. Metadata is captured at compile time and executed unchanged at run time.
For Nitpickers :)
This is not 100% true. The profiling API and ENC allow you to modify the metadata structure at runtime. But none of them are applicable for this scenario.
+1
source to share