例如:
Sub Test() Dim car as new MyCar car.chassis.wheel.radius = 15 Console.WriteLine(car.chassis.wheel.radius) End Sub
你可以,但不像你的问题那样简洁.
原文链接:https://www.f2er.com/vb/255523.htmlPublic Function GetPropertyValue(ByVal obj As Object,ByVal PropName As String) As Object Dim objType As Type = obj.GetType() Dim pInfo As System.Reflection.PropertyInfo = objType.GetProperty(PropName) Dim PropValue As Object = pInfo.GetValue(obj,Reflection.BindingFlags.GetProperty,Nothing,Nothing) Return PropValue End Function
我给你留下错误处理.任何后果:)