public override string ToString() { StringBuilder result = new StringBuilder(); result.AppendLine(this.Name.ToString()); result.AppendLine("Company:"); if (this.Company != null) { result.AppendLine(this.Company.ToString()); } result.AppendLine("Car:"); if (this.Car != null) { result.AppendLine(this.Car.ToString()); } result.AppendLine("Pokemon:"); if (Pokemons.Any()) { result.AppendLine(string.Join(Environment.NewLine, Pokemons)); } result.AppendLine("Parents:"); if (Parents.Any()) { result.AppendLine(string.Join(Environment.NewLine, Parents)); } result.AppendLine("Children:"); if (Children.Any()) { result.AppendLine(string.Join(Environment.NewLine, Children)); } return(result.ToString().TrimEnd()); }
public override string ToString() { string output = string.Empty; output = string.Concat(output, Name); output = string.Concat(output, Environment.NewLine); output = string.Concat(output, "Company:"); output = string.Concat(output, Environment.NewLine); if (Company != null) { output = string.Concat(output, Company.ToString()); output = string.Concat(output, Environment.NewLine); } output = string.Concat(output, "Car:"); output = string.Concat(output, Environment.NewLine); if (Car != null) { output = string.Concat(output, Car.ToString()); output = string.Concat(output, Environment.NewLine); } output = string.Concat(output, "Pokemon:"); output = string.Concat(output, Environment.NewLine); if (Pokemons.Any()) { foreach (var pokemon in Pokemons) { output = string.Concat(output, pokemon.ToString()); output = string.Concat(output, Environment.NewLine); } } output = string.Concat(output, "Parents:"); output = string.Concat(output, Environment.NewLine); if (Parents.Any()) { foreach (var parent in Parents) { output = string.Concat(output, parent.ToString()); output = string.Concat(output, Environment.NewLine); } } output = string.Concat(output, "Children:"); output = string.Concat(output, Environment.NewLine); if (Children.Any()) { foreach (var child in Children) { output = string.Concat(output, child.ToString()); output = string.Concat(output, Environment.NewLine); } } return(output); }