2
嗨,大家好我在互聯網上瀏覽自定義屬性。我把握這個概念,但是,驚訝和混淆,看到他們通過屬性類的構造函數設置屬性值作爲參數,它沒有將任何參數作爲構造函數的值。請澄清核心概念。自定義屬性的構造函數如何獲取可選參數
[DeBugInfo(45, "Zara Ali", "12/8/2012", **Message = "Return type mismatch"**)]
//like the Message here.
public class DeBugInfo : System.Attribute
{
private int bugNo;
private string developer;
private string lastReview;
public string message;
public DeBugInfo(int bg, string dev, string d)
{
this.bugNo = bg;
this.developer = dev;
this.lastReview = d;
}
public int BugNo
{
get
{
return bugNo;
}
public string Developer
{
get
{
return developer;
}
}
public string LastReview
{
get
{
return lastReview;
}
public string Message
{
get
{
return message;
}
set
{
message = value;
}
}
//////////////////////////