Skip to content

Instantly share code, notes, and snippets.

@syron
Created March 2, 2021 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syron/676434077b541ee639a42012214239e3 to your computer and use it in GitHub Desktop.
Save syron/676434077b541ee639a42012214239e3 to your computer and use it in GitHub Desktop.
public class Human
{
public string Name { get; set; }
public DateTime DateTimeOfBirth { get; set; }
}
public class NewPerson : Human
{
public int CalculateAge()
{
return 1;
}
}
public static class HumanExtensions
{
public static int CalculateAge(this Human human)
{
return 7331;
}
}
public static class StringExtensions
{
public static string HelloWorld(this string str)
{
return "Hello World";
}
}
public static class HumanHelper
{
public static int CalculateAge(Human human)
{
return 1337;
}
}
class Program
{
static void Main(string[] args)
{
Human person = new Human() { Name = "Ellie", DateTimeOfBirth = DateTime.Parse("2019-12-07 01:37") };
string name = "Robert";
Console.WriteLine(name.HelloWorld());
Console.WriteLine("Age: " + person.CalculateAge());
Console.WriteLine("Age: " + HumanHelper.CalculateAge(person));
List<string> names = new List<string>() { "Robert", "Mayer" };
Console.ReadLine();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment