I have a class as follows, its for an API so it must be in this format
public class Command
{
public string response_type { get; set; }
public string text { get; set; }
public Attachment[] attachments { get; set; } = new Attachment[] { new Attachment { } };
}
public class Attachment
{
public string title { get; set; }
public string title_link { get; set; }
public string image_url { get; set; }
}
So its a response_type, text and array of attachments. You can see I create the attachment array and create an empty object.
When creating the object there will only ever be one element in the array.
How do I set or add to the array when declaring the object, given the object is already created in the constructor
Command result = new Command()
{
text = "Rebooting!",
attachments[0] = ????
};
Im missing something simple, tried lots of combos