scope_creep
asked on
How to load a type instance into an object array i.e. object[]
How to load a type into an object array.
I have this.
public partial class Message
{
private object[] itemsField;
private decimal versionField;
private bool versionFieldSpecified;
public Message()
{
this.versionField = ((decimal)(1.0m));
}
/// <remarks/>
[System.Xml.Serialization. XmlElement Attribute( "Mess", typeof(Mess))]
[System.Xml.Serialization. XmlElement Attribute( "Heartbeat ", typeof(Heartbeat))]
public object[] Items
{
get
{
return this.itemsField;
}
set
{
this.itemsField = value;
}
}
I have the following code.
Message OutBoundMessage = new Message();
Alert Alert = new Alert();
OutBoundMessage.Items = ((Alert) Alert); -----> This line does not work.
How can I load the alert class into the object array.
regards
scope_creep
I have this.
public partial class Message
{
private object[] itemsField;
private decimal versionField;
private bool versionFieldSpecified;
public Message()
{
this.versionField = ((decimal)(1.0m));
}
/// <remarks/>
[System.Xml.Serialization.
[System.Xml.Serialization.
public object[] Items
{
get
{
return this.itemsField;
}
set
{
this.itemsField = value;
}
}
I have the following code.
Message OutBoundMessage = new Message();
Alert Alert = new Alert();
OutBoundMessage.Items = ((Alert) Alert); -----> This line does not work.
How can I load the alert class into the object array.
regards
scope_creep
The Items property is an array of "object" but you are trying to set it to a single object.
Gary Davis
Gary Davis
ASKER
Ignore this question, I answered it myself.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have the following code.
Message OutBoundMessage = new Message();
Mess Mess = new Mess();
OutBoundMessage.Items = ((Mess) Mess); -----> This line does not work.
I get this. Cannot convert type Mess to object[]
thanks.
Bob