Skip to content

Instantly share code, notes, and snippets.

@dlemstra
Last active January 16, 2020 14:57
Show Gist options
  • Save dlemstra/407015580ec2010f32660118be960e9c to your computer and use it in GitHub Desktop.
Save dlemstra/407015580ec2010f32660118be960e9c to your computer and use it in GitHub Desktop.
using System;
namespace WeirdDynamic
{
class Program
{
static void Main(string[] args)
{
var foo = CreateFoo();
var bar = CreateBar(foo.Id);
Console.WriteLine(bar.Id);
}
static Bar CreateBar(int id) => new Bar(id);
static dynamic CreateFoo() => new { Id = 42 };
class Bar
{
public Bar(int id) { }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment