Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- //Console.WriteLine("Hello, World!");
- var per = new Person("Angelo", "Cardenas");
- PrintObject.Print<Person>(per, p => $"El nombre completo es: {p.LastName} {p.Name}");
- }
- }
- public class Person{
- public string Name {get; set;}
- public string LastName {get; set;}
- public Person(string name, string lastName)
- {
- Name = name;
- LastName = lastName;
- }
- }
- public class PrintObject
- {
- public static void Print<T>(T obj, Func<T, string> names) => Console.WriteLine(names.Invoke(obj));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement