public override string ToString()
{
var sb = new StringBuilder();
sb.AppendFormat("Name: {1}{0}Age:{2}{0}", Environment.NewLine, this.Name, this.Age);
if (!(string.IsNullOrEmpty(this.Email)))
{
sb.AppendFormat("Email:{0}", this.Email);
}
return sb.ToString();
}
public static void Main(string[] args) { Person personWithAge = new Person("Unufri", 12); Person personWithoutAge = new Person("Ani"); Console.WriteLine(personWithAge.ToString()); Console.WriteLine(personWithoutAge.ToString()); }