I have a class like this:
class Zmogus
{
public string Vardas { get; set; }
public int Draugu_Kiekis { get; set; }
public string[] Draugas { get; set; }
public Zmogus(string vardas, int draugu_Kiekis, string[] draugas)
{
Vardas = vardas;
Draugu_Kiekis = draugu_Kiekis;
Draugas = draugas;
}
public Zmogus()
{
}
}
And i would like to know how to determine the size of it, because when i use it like this:
zmogus.Draugas[i] = parts[i+2];
It just shows me that the "Draugai" parameter is null.
Add the property: public int DraugasLength{get {return this.Draugas.Length} set;}
or just use Draugas.Length
. I think that behavior you are looking for is more like list than array - I would recommend using List from System.Collections.Generic instead of arrays.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.