Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person
- {
- string FName {get;set;}
- string LNAme {get; set;}
- int Age {get;set;}
- public string ToString(Person obj)
- {
- string result = string.Empty;
- obj.GetType().GetProperties().ToList().ForEach(p =>
- {
- result += string.Concat(p.Name + ": " + p.GetValue(obj) + "\r\n");
- });
- return result;
- }
- }
- //This is nice becasue you don't have to worry about how many properties you add, delete or change
Advertisement
Add Comment
Please, Sign In to add comment