所以,说我有以下内容:
public class CProperty : CTitledEntity
{
private int numberOfNodes;
private int elementType;
public CProperty(int id, string title, int numberOfNodes, int elementType, string descripton = "")
: base(id, title, descripton)
{
this.numberOfNodes = numberOfNodes;
this.elementType = elementType;
}
public string Property
{
get
{
CElement.ElementTypes enumDisplayStatus = ((CElement.ElementTypes)numberOfNodes);
string stringValue = enumDisplayStatus.ToString();
return stringValue + elementType;
}
}
}
和
public CElement(int id, int numberOfNodes, int index, int[] nodes)
: base(id)
{
this.NumberOfNodes = numberOfNodes;
this.Nodes = new int[numberOfNodes];
this.Index = index;
for (int i = 0; i < numberOfNodes; i++)
this.Nodes[i] = nodes[i];
}
public int NumberOfNodes { get; set; }
public int[] Nodes { get; set; }
public int Index { get; set; }
public CProperty Property { get; set; }
我有一份清单:
CEntityCollection<CProperty> properties = ReadProperty();
CEntityCollection<CElement> elements = ReadElement();
首先,我很抱歉我的英语不好。 我必须使用CPropety param.CProperty param在CElement类中创建构造函数。我从属性给出。我不知道该怎么做。
答案 0 :(得分:0)
只需在Element类中添加Property对象,并将其添加到构造函数的参数中。
public CElement(int id, int numberOfNodes, int index, int[] nodes, CProperty property) : base(id)
: base(id)
{
this.NumberOfNodes = numberOfNodes;
this.Nodes = new int[numberOfNodes];
this.Index = index;
for (int i = 0; i < numberOfNodes; i++)
this.Nodes[i] = nodes[i];
Property = property;
}
public CProperty Property { get; set; }
public int NumberOfNodes { get; set; }
public int[] Nodes { get; set; }
public int Index { get; set; }
public CProperty Property { get; set; }