自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

.NET 獲取類型中的屬性

開發(fā)
解決方案:通過反射的方式獲取類型中的所有屬性。

解決方案

通過反射的方式獲取類型中的所有屬性。

引用命名空間

  1. using System.Reflection; 

實體類

  1. public class User 
  2.   { 
  3.         private string id; 
  4.         public string Id { get { return id; } set { id = value; } } 
  5.  
  6.         private string name; 
  7.         public string Name { get { return name; } set { name = value; } } 
  8.   } 

獲取方法

  1. private PropertyInfo[] GetPropertyInfoArray() 
  2.    { 
  3.         PropertyInfo[] props = null
  4.         try 
  5.         { 
  6.              Type type = typeof(User); 
  7.              object obj = Activator.CreateInstance(type); 
  8.              props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); 
  9.         } 
  10.         catch (Exception ex) 
  11.         { } 
  12.         return props; 
  13.    } 

原文鏈接:http://www.cnblogs.com/liusuqi/p/3171963.html

責(zé)任編輯:陳四芳 來源: M守護(hù)神
相關(guān)推薦

2009-07-22 17:55:52

2009-08-04 17:30:23

cookieless屬ASP.NET

2009-11-12 13:19:55

2024-11-27 00:24:04

2011-04-13 14:37:35

十進(jìn)制浮點.NET

2009-12-04 09:14:05

.NET 4.0

2011-06-08 13:50:39

C#類型轉(zhuǎn)換

2009-07-28 13:17:09

EnableViewSASP.NET

2009-07-23 17:07:58

2009-12-01 09:30:34

ASP.NET MVC

2009-10-26 15:26:37

VB.NET屬性

2009-03-02 13:56:29

2011-08-04 09:43:11

ASP.NET控件

2009-07-29 15:07:23

Request對象的屬

2009-10-10 09:53:07

.NET值類型

2010-05-06 17:46:47

2023-11-20 14:41:34

Python屬性

2023-12-01 10:20:04

Python類屬性

2009-07-29 09:34:54

IsPostBack屬ASP.NET

2009-10-22 10:10:20

VB.NET Proc
點贊
收藏

51CTO技術(shù)棧公眾號