ChrisA <Ch****@discussions.microsoft.com> wrote:
I have an array of 'struct' with three string fields which I would like to
initialize.
Is this possible?
public struct Role
{
string a; string b; string c;
}
...
Role[] roles = ?? ( {"1","2","3"}, {"4","5","6"} };
Not quite, no. You'd need:
public struct Role
{
string a, b, c;
public Role (string a, string b, string c)
{
this.a = a;
this.b = b;
this.c = c;
}
}
then
Role[] roles = new Role[] { new Role ("1", "2", "3"),
new Role ("4", "5", "6") };
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too