我有一个责任类,其中包含一些子类下面是该类:-
public class Responsibility
{
private Frequency _FrequencyInfo = new Frequency();
private ResponsibilityCategory _CategoryInfo = new ResponsibilityCategory();
private Status _StatusInfo = new Status();
public int ResponsibilityId { get; set; }
public string ResponsibilityName { get; set; }
public string Description { get; set; }
public Frequency FrequencyInfo
{
get { return _FrequencyInfo; }
set { _FrequencyInfo = value; }
}
public ResponsibilityCategory CategoryInfo
{
get { return _CategoryInfo; }
set { _CategoryInfo = value; }
}
public Status StatusInfo
{
get { return _StatusInfo; }
set { _StatusInfo = value; }
}
}
下面是我用来绑定列表的代码。但我得到了类的所有元素。我只想要类中的两个元素。
Responsibility newResponsibilty = new Responsibility();
newResponsibilty.ResponsibilityId = ResponsibilityId;
new iNGRID_Data.Ops.DataMethods().dbrGetResponsibilityDetailsInSpecifiedResponsibilty(ref newResponsibilty, ResponsibilityId, ref err);
List<Responsibility> listResponsibilty = new List<Responsibility>();
listResponsibilty.Add(newResponsibilty);
JavaScriptSerializer jsonserialize = new JavaScriptSerializer();
string result = jsonserialize.Serialize(listResponsibilty);
return Content(result);
我想用 2 个对象 ResponsibiltyName 和 Description 序列化这个列表。请建议。