Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created March 22, 2013 15:23
Show Gist options
  • Select an option

  • Save masaru-b-cl/5222118 to your computer and use it in GitHub Desktop.

Select an option

Save masaru-b-cl/5222118 to your computer and use it in GitHub Desktop.
DynamicObjectのTry~でfalseを返すと・・・
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class MyDynamic : DynamicObject
{
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
result = binder.Name;
return false;
}
}
class Program
{
static void Main(string[] args)
{
dynamic clazz = new MyDynamic();
Console.WriteLine(clazz.hoge);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment