校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > Attribute/特性心得隨筆

Attribute/特性心得隨筆

熱門標簽:外呼系統代理品牌 怎么給超市做地圖標注入駐店 外呼系統費用一年 辦理400電話證件 巫師3為什么地圖標注的財寶沒有 十堰正規電銷機器人系統 手機地圖標注如何刪除 世紀佳緣地圖標注怎么去掉 寧波自動外呼系統代理
復制代碼 代碼如下:

p>/*/p>p>*特性/p>p>*//p>

復制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// summary>
/// DisAttribute 的摘要說明
/// /summary>
public class DisAttribute : Attribute
{
private string _message;
/// summary>
/// 描述
/// /summary>
public string Message
{
get { return _message; }
}

public DisAttribute(string message)
{
this._message = message;
}
}

/*

*類

*/
復制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.EnterpriseServices;
using System.Linq;
using System.Web;
using System.Web.DynamicData;


/// summary>
/// User 的摘要說明
/// /summary>
[DisAttribute("User"),TableName("user"),Description("user")]
public class User
{
private int? _id;
/// summary>
/// Id
/// /summary>
[DisAttribute("主鍵")]
public int? Id
{
get { return _id; }
set { _id = value; }
}


private string _name;
/// summary>
/// 名稱
/// /summary>
[DisAttribute("名稱")]
public string Name
{
get { return _name; }
set { _name = value; }
}
}

/*

*獲取

*/
復制代碼 代碼如下:

//獲取特性
User u = new User();
Type _t = u.GetType();
foreach (Attribute a in _t.GetCustomAttributes(true))
{
if (a.GetType().ToString() == "DisAttribute")
{
DisAttribute _da = (DisAttribute)a;
if (_da != null)
{
Response.Write(_da.Message + "br>");
}
}
}
//獲取所有屬性
u.Id = 888888;
u.Name = "陳奕迅";
foreach (PropertyInfo item in _t.GetProperties())
{
//特性
Attribute atr = item.GetCustomAttribute(typeof(DisAttribute));
if (atr.GetType().ToString() == "DisAttribute")
{
DisAttribute _da = (DisAttribute)atr;
if (_da != null)
{
Response.Write(_da.Message + "br>");
}
}
}

標簽:泰州 山西 通遼 平涼 天門 景德鎮 牡丹江 嘉興

巨人網絡通訊聲明:本文標題《Attribute/特性心得隨筆》,本文關鍵詞  Attribute,特性,心得,隨筆,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Attribute/特性心得隨筆》相關的同類信息!
  • 本頁收集關于Attribute/特性心得隨筆的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 寿宁县| 商南县| 东兰县| 观塘区| 奎屯市| 南康市| 乌拉特中旗| 武义县| 拉萨市| 响水县| 五华县| 清河县| 克拉玛依市| 静乐县| 富锦市| 亳州市| 新津县| 乌拉特后旗| 靖远县| 南城县| 东乡县| 达州市| 象州县| 乳山市| 青田县| 铜梁县| 沿河| 奉贤区| 宕昌县| 宁乡县| 明水县| 商城县| 德钦县| 遵义市| 孙吴县| 潜山县| 清远市| 平凉市| 疏勒县| 琼结县| 迭部县|