(動的に追加された) プロパティを返す動的メソッドを ExpandoObject に追加しようとしていますが、常にエラーが発生します。
私はここで何か間違っていますか?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Dynamic;
namespace DynamicDemo
{
class ExpandoFun
{
public static void Main()
{
Console.WriteLine("Fun with Expandos...");
dynamic student = new ExpandoObject();
student.FirstName = "John";
student.LastName = "Doe";
student.Introduction=new Action(()=>
Console.WriteLine("Hello my name is {0} {1}",this.FirstName,this.LastName);
);
Console.WriteLine(student.FirstName);
student.Introduction();
}
}
}
コンパイラは次のエラーにフラグを立てています: エラー 1
キーワード 'this' は、静的プロパティ、静的メソッド、または静的フィールド初期化子では無効です
D:\rnd\GettingStarted\DynamicDemo\ExpandoFun.cs 20 63 DynamicDemo