資源描述:
《c反射獲得類名,私有方法,動態(tài)執(zhí)行方法,返回多個值》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、直接上例子了,廢話不多說,大家一看就懂。代碼內(nèi)容:實(shí)體類:publicclassuserinfo???{???????publicuserinfo()???????{}???????#region成員???????privateint_userid;???????privatestring_username;???????privatestring_password;???????privateint_roleid;???????privatestring_telephone;???????privatestr
2、ing_usersex;???????privatestring_address;???????privatestring_email;???????privatestring_logintime;???????privatestring_createtime;???????#endregion???????#region屬性???????publicintuserid???????{???????????get{return_userid;}???????????set{_userid=value;}????
3、???}???????publicstringusername???????{???????????get{return_username;}???????????set{_username=value;}???????}???????publicstringpassword???????{???????????get{return_password;}???????????set{_password=value;}???????}???????publicintroleid???????{??????????
4、?get{return_roleid;}???????????set{_roleid=value;}???????}???????publicstringtelephone???????{???????????get{return_telephone;}???????????set{_telephone=value;}???????}???????publicstringusersex???????{???????????get{return_usersex;}???????????set{_usersex=v
5、alue;}???????}???????publicstringaddress???????{???????????get{return_address;}???????????set{_address=value;}???????}???????publicstringemail???????{???????????get{return_email;}???????????set{_email=value;}???????}???????publicstringlogintime???????{??????
6、?????get{return_logintime;}???????????set{_logintime=value;}???????}???????publicstringcreatetime???????{???????????get{return_createtime;}???????????set{_createtime=value;}???????}???????privatestringReturnAutoID()???????{???????????return"userid";???????}?
7、??????#endregion???}反射方法類:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Reflection;namespaceReflecti{???publicclassGetModelInfo???{???????///???????///通過反射獲得對象名稱和自動增長ID???????///???????///8、ame="obj">對象???????///返回string數(shù)組???????publicstaticstring[]Core(Objectobj)???????{???????????string[]str=newstring[2];???????????TypeT=obj.GetType();???????????MethodI