Last active
February 12, 2020 18:45
-
-
Save danielcrenna/fe4411b035f5cf2590e411ef1948c6fe to your computer and use it in GitHub Desktop.
[TypeKitchen] Hello, World!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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