Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created September 5, 2012 01:11
Show Gist options
  • Save masaru-b-cl/3628787 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/3628787 to your computer and use it in GitHub Desktop.
dynamicでobject型引数と闘う
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SomeMethod(new { Name = "Taro" });
}
static void SomeMethod(object arg)
{
dynamic a = arg;
string name = a.Name;
Console.WriteLine(name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment