I have a struct that I created specific for a usercontrol. My thought was that I would have a public property Guid Dictionary<string, Guid> Attachments and then convert that to my private List<Attachment> attachments on the setter. I’m having trouble doing that, preferably with linq but I’m open to alternatives. Thank you…
private List<Attachment> attachments;
public struct Attachment
{
public Guid Id { get; set; }
public string Name { get; set; }
}
public Dictionary<string, Guid> Attachments
{
get { return attachments.ToDictionary(a => a.Name, a => a.Id); }
set { attachments = new List<Attachment> // not sure what to do here }
}
Assuming this is a valid design (I haven’t really thought about it) I suspect you want:
I would strongly discourage you from using a mutable struct though. Using a struct isn’t too bad in itself, but I’d change it to:
… at which point the conversion is just: