Advertisement
Guest User

DemoApp (C# Shell App Paste)

a guest
Dec 10th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.     public static class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.            //Console.WriteLine("Hello, World!");
  14.            var per = new Person("Angelo", "Cardenas");
  15.            PrintObject.Print<Person>(per, p => $"El nombre completo es: {p.LastName} {p.Name}");
  16.         }
  17.     }
  18.  
  19.     public class Person{
  20.         public string Name {get; set;}
  21.         public string LastName {get; set;}
  22.        
  23.         public Person(string name, string lastName)
  24.         {
  25.             Name = name;
  26.             LastName = lastName;
  27.         }
  28.     }
  29.    
  30.     public class PrintObject
  31.     {
  32.         public static void Print<T>(T obj, Func<T, string> names) => Console.WriteLine(names.Invoke(obj));
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement