A
Andy B
I am trying to create a property of a class that holds a collection. Inside
the main class is a property that is defined as a collection. When I try to
assign values to it I keep getting all sorts of errors. The main one that I
get now is 'Can't convert Contracts.ContractModel.ContractDefinitions
collection to Contracts.ContractModel.Definition type'.
inside the main Contract class I have the Definitions collection property:
private ContractDefinitions Definitions=null;
public ContractDefinitions Definitions {
get { return this.Definitions; }
set {thisDefinitions=value; }
}
ContractDefinitions is the collection of Definition types. Here is what I
end up getting when I try to assign Definitions to the collection:
//Create a contract object. This works fine
Contract Contract = new Contract();
//create some definitions. This works as well...
Definition Host = new Definition);
Host.Word="Host";
Host.Definition1="A person who pays for and signs the contract";
//Assign the Definition to the collection class by creating it. These 2
lines give me a 'can't convert ContractDefinitions collection to Definition
type' error.
Contract.Definitions.Add(Host); //I get object reference set to a null
reference error//try it by creating an instance of the Deffinitions
collection
ContractDefinitions DefinitionsCollection = new ContractDefinitions();
DefinitionsCollection.Add(Host);
I also tried different ways as well but cant quite figure out how to do
this. The entire 20 class contract set was created from xsd file. Is there
any way I can get this to work?
the main class is a property that is defined as a collection. When I try to
assign values to it I keep getting all sorts of errors. The main one that I
get now is 'Can't convert Contracts.ContractModel.ContractDefinitions
collection to Contracts.ContractModel.Definition type'.
inside the main Contract class I have the Definitions collection property:
private ContractDefinitions Definitions=null;
public ContractDefinitions Definitions {
get { return this.Definitions; }
set {thisDefinitions=value; }
}
ContractDefinitions is the collection of Definition types. Here is what I
end up getting when I try to assign Definitions to the collection:
//Create a contract object. This works fine
Contract Contract = new Contract();
//create some definitions. This works as well...
Definition Host = new Definition);
Host.Word="Host";
Host.Definition1="A person who pays for and signs the contract";
//Assign the Definition to the collection class by creating it. These 2
lines give me a 'can't convert ContractDefinitions collection to Definition
type' error.
Contract.Definitions.Add(Host); //I get object reference set to a null
reference error//try it by creating an instance of the Deffinitions
collection
ContractDefinitions DefinitionsCollection = new ContractDefinitions();
DefinitionsCollection.Add(Host);
I also tried different ways as well but cant quite figure out how to do
this. The entire 20 class contract set was created from xsd file. Is there
any way I can get this to work?