Is it possible to make array size size depended on the atribute value(int)?
class trip { private person[] arrayofpeople; public person[] arrayofpeople
get { return arrayofpeople; }
set { arrayofpeople = value; }}
class ship { private int numberofrooms; public int numberofrooms { { return numberofrooms; } set { numberofrooms = value; } } }question how can make when make new object type trip, arrayofpeople size of numberofrooms?
hi damjan,
maybe it's typo, public property in trip class should called arrayofpeople, because private variable called arrayofpeople (you did correctly in ship class). you'll need when setting arrayofpeople trip:
ship myship = new ship(); myship.numberofrooms = 6; trip mytrip = new trip(); mytrip.arrayofpeople = new person[myship.numberofrooms];
~~bonnie dewitt [c# mvp]
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment