C#中的partial關鍵字的作用
使用partial修飾的類可以在同一個檔案下面寫相同的類名,簡單的理解就是可以動態的新增欄位:
public partial class ManagerMenu
{
public int id { get; set; }
public string text { get; set; }
public int parentId { get; set; }
public bool statu { get; set; }
}
}
另一個C#類
public partial class ManagerMenu
{
public bool idChecked { get; set; }
public TreeNode transformTreeNode()
{
TreeNode treeNode = new TreeNode
{
id = this.id,
text = this.text,
state = this.statu == true ? "open" : "closed",
check = false,
attributes = new { Url = "#" },
children = new List<TreeNode>()
};
return treeNode;
}
}
詳細說明:http://www.cnblogs.com/OpenCoder/archive/2009/10/27/1590328.html