vb.net反射中如何将字符串转化为对象实例
发布时间:2020-12-17 08:10:19 所属栏目:百科 来源:网络整理
导读:Imports System.Reflection Public Class Form1 Private Sub Button1_Click( ByVal sender As System.Object,255)">ByVal e As System.EventArgs) Handles Button1.Click Dim o As Object = Activator.CreateInstance(Type.GetType( " A.a " )) ' 工程名称.
Imports System.Reflection
Public Class Form1 Private Sub Button1_Click( ByVal sender As System.Object,255)">ByVal e As System.EventArgs) Handles Button1.Click Dim o As Object = Activator.CreateInstance(Type.GetType( " A.a ")) ' 工程名称.类名 Dim MyProperty As PropertyInfo = o.GetType().GetProperty( NAME ") Dim objValue Object = " Bbb " MyProperty.SetValue(o,objValue,255)">Nothing) Dim objReturn() Object MsgBox(MyProperty.GetValue(o,objReturn).ToString()) End Sub End Class Class a private _name String Public _id Integer Property NAME() As String Get Return _name End Get Set( ByVal value String) _name = value Set End Property End Class (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |