I am trying to create an struct-array. I used the example provided by @JonSkeet found in this SO post to create the example below:
public class JonSkeetClass
{
public struct ReportDetails
{
private readonly int indexd;
private readonly string name;
public ReportDetails(int indexd, string name)
{
this.indexd = indexd;
this.name = name;
}
public int Indexd { get { return indexd; } }
public string Name { get { return name; } }
}
static readonly IList<ReportDetails> MyArray = new ReadOnlyCollection<ReportDetails>
(
new[]
{
new ReportDetails(0, "Daily Unload Counts by Group"),
new ReportDetails(1,"Daily Unloads")
});
public statis IList<ReportDetails> GetMyArray
{
get{ return MyArray; }
}
}
I am now unsure how to use this class in my code as the MyArray IList is not exposing any methods or properties.
Update1: Code sample above has been updated with the suggestion from @Adrian.
To initialize:
IList<JonSkeetClass.ReportDetails> MyArray = JonSkeetClass.GetMyArray;
MessageBox.Show( MyArray[0].Name.ToString());