新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
.NET獲取類型中的屬性
解決方案

創(chuàng)新互聯(lián)專注于石河子網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供石河子營銷型網(wǎng)站建設(shè),石河子網(wǎng)站制作、石河子網(wǎng)頁設(shè)計、石河子網(wǎng)站官網(wǎng)定制、成都小程序開發(fā)服務(wù),打造石河子網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供石河子網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
通過反射的方式獲取類型中的所有屬性。
引用命名空間
- using System.Reflection;
實體類
- public class User
- {
- private string id;
- public string Id { get { return id; } set { id = value; } }
- private string name;
- public string Name { get { return name; } set { name = value; } }
- }
獲取方法
- private PropertyInfo[] GetPropertyInfoArray()
- {
- PropertyInfo[] props = null;
- try
- {
- Type type = typeof(User);
- object obj = Activator.CreateInstance(type);
- props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
- }
- catch (Exception ex)
- { }
- return props;
- }
網(wǎng)頁標題:.NET獲取類型中的屬性
路徑分享:http://www.5511xx.com/article/dhjojcd.html


咨詢
建站咨詢
