The answer from tehMick actually throws a run-time exception in .NET 2.0, but other than that, the example is straight to the point.
Types of a two-dimensional array must have a publicly accessible property, so you can access it directly, as you said:
public class DTO
{
private String myStrProperty;
public String MyStrProperty
{
get {return myStrProperty; }
set { myStrProperty = value; }
}
public DTO(string myStrProperty)
{
this.myStrProperty = myStrProperty;
}
}
class Program
{
private static Logger logger;
static void Main(string[] args)
{
DTO[,] matrix =
{
{new DTO("label1"), new DTO("label2")},
{new DTO("label3"), new DTO("label4")}
};
matrix[0, 1].MyStrProperty = "otherValue";
}
}
mamoo source
share