Skip to content

Instantly share code, notes, and snippets.

@danielcrenna
Last active February 12, 2020 18:45
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 danielcrenna/fe4411b035f5cf2590e411ef1948c6fe to your computer and use it in GitHub Desktop.
Save danielcrenna/fe4411b035f5cf2590e411ef1948c6fe to your computer and use it in GitHub Desktop.
[TypeKitchen] Hello, World!
// Copyright (c) Daniel Crenna & Contributors. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace TypeKitchen.HelloWorld
{
internal class SimpleType
{
public string ThisIsAString { get; set; }
}
internal class Program
{
private static void Main()
{
// Some structure, known in advance or at runtime
var instance = new SimpleType { ThisIsAString = "Yep!" };
//
// Direct access (known in advance):
Console.WriteLine(instance.ThisIsAString);
//
// Implicit access (known at runtime):
Console.WriteLine(ReadAccessor.Create(typeof(SimpleType))[instance, nameof(SimpleType.ThisIsAString)]);
if(Environment.UserInteractive)
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment