Persons.Person.ToString C# (CSharp) 메소드

ToString() 공개 메소드

public ToString ( ) : string
리턴 string
        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();
        }

Usage Example

예제 #1
0
        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());
        }
All Usage Examples Of Persons.Person::ToString